MySQL - SELECT * FROM tableWHERE date = TODAY
An SQL query that selects all the records in a table with today as their date value:
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)
Click the link more information about MySQL Date and Time functions on the official MySQL site.


