How to compare today’s date with the one you have in the MySQL timestamp field

Say you have a field called date in your MySQL table and its type is timestamp (example: '2014-08-23 08:37:57'), and you want to get all the records for today (so, all the records who's dates are '2014-08-23' neverminding the time). Here's how yo do that:

SELECT * FROM `the_table` WHERE date(date) = curdate();

So, we're using date() and curdate() functions here to help us achieve that.

Written by Nikola Brežnjak