Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:39:26+00:00 2026-06-09T03:39:26+00:00

In the database column called date (tyupe int(11) ) I have stored the date

  • 0

In the database column called date (tyupe int(11)) I have stored the date as integer. Then, I have variables $day, $month, $year and I would need to get all rows for the respective day (which represent variables $day, $month, $year).

How to do that?

I’ve tried this way:

mysql_query("SELECT id FROM persons WHERE DATE_FORMAT( `date` , '%Y-%m-%d' ) =
            '".date("$year-$month-$day")."'")

But this unfortunately doesn’t works me… Could anyone give me a tip, please, how to solve this problem?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:39:28+00:00Added an answer on June 9, 2026 at 3:39 am

    You’ll want to avoid having to wrap your date column in a function in order to still be able to utilize indexes.

    This is the most efficient method for your scenario, provided you have an index set up on the date column:

    $input_date = mktime(0, 0, 0, $month, $day, $year);
    mysql_query("SELECT id FROM persons WHERE date = $input_date");
    

    It would be an even better idea to actually store the date column as an actual DATE type. That way, you can make all sorts of compelling date comparisons and calculations that you otherwise couldn’t with a simple integer-based unix timestamp.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In mysql database i have this column called: Name: Date Type: datetime I have
In database table I have column called options . It has type of integer
I have an sqlite database which currently holds an integer field called Year which
I have a existing MySQL database with a column called month_year. It has date/time
I have a database table with a column called 'symbol', that is unique via
I have some files stored in a database blob column in Oracle 9. I
I have a column in my drupal database called field_concert_published_value which is storing the
I have a column in my database's messages table. It is called status and
How do I insert the current date to my database? I have a column
I have a mysql database table with a column called task_end_date and task_name. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.