Date Added: Saturday 18th of April 2009 » Section: Web Development Tutorials

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:

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

Font Size: decrease the font size increase the font size
:

Random Photographs

Web Development Tips & Tricks

Web Development RSS Feed

God Bless The Internet

Web Development RSS Feed

The Fight Club Polls

Who'd win in a fight between Rambo and Rocky?

Rambo vs Rocky
Rambo
Rocky

Ramboscore 63%
Rockyscore 36%
248 votes so far...

Platform and Web Standards: W3C HTML 4.01 Standards W3C CSS 2.1 Standards Powered by PHP Powered by MYSQL RSS Valid Recommend Firefox Page copy protected against web site content infringement by Copyscape