t_machine Posted November 13, 2008 Share Posted November 13, 2008 hi, I have a table that stores dates with the mysql CURRENT_TIMESTAMP. This stores each entry with the format (2008-11-12 00:11:08). The problem I am having is getting the results for the current date. The following query will explain what I mean. $sql = "SELECT * FROM my_table WHERE date_field = CURDATE()"; This does not give any results even though the current date is the same as a few records in the database. Any help would be greatly appreciated. Thanks:) Quote Link to comment https://forums.phpfreaks.com/topic/132516-solved-how-to-get-results-for-current-date/ Share on other sites More sharing options...
zenag Posted November 13, 2008 Share Posted November 13, 2008 SELECT DATE_FORMAT( date_field, '%Y-%m-%d' ) FROM `my_table` WHERE date_field = CURDATE( ) Quote Link to comment https://forums.phpfreaks.com/topic/132516-solved-how-to-get-results-for-current-date/#findComment-689092 Share on other sites More sharing options...
t_machine Posted November 13, 2008 Author Share Posted November 13, 2008 Thank you very much, works perfectly Quote Link to comment https://forums.phpfreaks.com/topic/132516-solved-how-to-get-results-for-current-date/#findComment-689096 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.