MySQL – SELECT * FROM table WHERE date = TODAY

mySQL SELECT WHERE date = today
mySQL SELECT WHERE date = today

The Quick answer is:

SELECT * FROM myTable WHERE DATE(myDate) = DATE(NOW())

I was tearing my hair out trying to figure this the other morning and its really quite simple. I thought i may have use a day month year match or possibly use PHP but thankfully the guys at MySQL included this nice DATE() function which means you don’t have to worry about the hours, minutes and seconds being different. Simples!
MySQL DATE / TIME Functions

The functions used in thie MySQL query are:

* DATE() returns the date without time
* NOW() returns the current date & time (note we’ve used the DATE() function in this query to remove the time)

For more information about MySQL Date and Time functions on the official MySQL site.

18 thoughts on “MySQL – SELECT * FROM table WHERE date = TODAY”

    1. Sorry, I have to correct my last comment. The above doesn’t work. The correct query looks like this:
      SELECT * FROM TABLE WHERE `DATE` >= DATE_SUB(CURDATE(),INTERVAL 3 DAY)

    2. But that loses the date formatting, so you can do this:

      DATE(my_date) = DATE(CURDATE()-2)

      which would find anything from 2 days ago.

  1. Thanks for the help with the MySQL query.

    By the way, your photos in the sidebar are pointing to an IP on your local network. I wanted to see those bridge pics!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.