Sometimes I have a datetime or timestamp columns in the database and, for example, I need to select all records with timestamp updated today.
I usually do it like this:
SELECT * FROM mytable WHERE CAST(TS AS DATE) = CURDATE();
SELECT * FROM mytable WHERE CAST(TS AS DATE) = '2009-11-01';
Also, it's possible to use DATE() function instead of cast:
SELECT * FROM mytable WHERE DATE(TS) = CURDATE();
The question is which way is more correct and faster? Because I'm not sure CAST for all records is a very good idea, maybe there is a better way...