waynew Posted November 20, 2008 Share Posted November 20, 2008 I have a datetime column in one of my tables, which means that every looks a bit like: 2008-11-20 11:58:00 Now, I want to show every record for today. So I would get todays date like so: $current_date = date("Y-m-d"); Now, how would I select all records that relate to todays date? I'm pretty sure that you can't do something like: WHERE dateOrder = '$current_date' As the datetime column includes the hour, and not just the date. Anyone wishing to shed the light? Link to comment https://forums.phpfreaks.com/topic/133486-solved-small-date-question/ Share on other sites More sharing options...
Mchl Posted November 20, 2008 Share Posted November 20, 2008 WHERE DATE(dateOrder) = CURDATE() Link to comment https://forums.phpfreaks.com/topic/133486-solved-small-date-question/#findComment-694255 Share on other sites More sharing options...
waynew Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks! How would I go about getting tomorrows date? Or, a user-selected date? Link to comment https://forums.phpfreaks.com/topic/133486-solved-small-date-question/#findComment-694256 Share on other sites More sharing options...
Mchl Posted November 20, 2008 Share Posted November 20, 2008 that's usually task for PHPs strtotime $date = date("Y-m-d",strtotime("tomorrow")); $query = "SELECT ... WHERE DATE(dateOrder) = $date"; Link to comment https://forums.phpfreaks.com/topic/133486-solved-small-date-question/#findComment-694258 Share on other sites More sharing options...
waynew Posted November 20, 2008 Author Share Posted November 20, 2008 Ah! Now I see...! Thanks a mill. Link to comment https://forums.phpfreaks.com/topic/133486-solved-small-date-question/#findComment-694263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.