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.

show some love!
0saves

If this post helped you out, show some love above!. it only takes 2 seconds to Like/G+ or Tweet and you'll help me and other people looking for the content. Much Appreciated!

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

  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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>