adzie Posted April 20, 2009 Share Posted April 20, 2009 Hello folks, I want to be able to select information from my table by date so i want to select where the date field is todays date Link to comment https://forums.phpfreaks.com/topic/154884-select-by-date/ Share on other sites More sharing options...
envexlabs Posted April 20, 2009 Share Posted April 20, 2009 $today = date('YOUR DATE FORMAT'); $select = mysql_query("SELECT * FROM `table` WHERE `date` = '$date'"); Link to comment https://forums.phpfreaks.com/topic/154884-select-by-date/#findComment-814637 Share on other sites More sharing options...
The Little Guy Posted April 20, 2009 Share Posted April 20, 2009 It all depends on how you have your date field set up in the database, but if you have it set up using one of mysql dates, you could use one of these: $select = mysql_query("SELECT * FROM `table` WHERE `date` = CURDATE()"); $select = mysql_query("SELECT * FROM `table` WHERE `date` = NOW()"); $select = mysql_query("SELECT * FROM `table` WHERE `date` = DATE_FORMAT(date,format)"); Link to comment https://forums.phpfreaks.com/topic/154884-select-by-date/#findComment-814651 Share on other sites More sharing options...
adzie Posted April 20, 2009 Author Share Posted April 20, 2009 thanks chaps, yes its a datetime field Link to comment https://forums.phpfreaks.com/topic/154884-select-by-date/#findComment-814658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.