adzie Posted April 23, 2009 Share Posted April 23, 2009 Hello folks I want to be able to select records only with todays date. The date field is a datetime field. $number = mysql_num_rows(mysql_query("SELECT * FROM records WHERE user_id = '$users[opened]' AND active = '1' and date = 'today'")); Link to comment https://forums.phpfreaks.com/topic/155385-records-from-todays-date/ Share on other sites More sharing options...
jonsjava Posted April 23, 2009 Share Posted April 23, 2009 $number = mysql_num_rows(mysql_query("SELECT * FROM records WHERE user_id = '$users[opened]' AND active = '1' and date = CURRENT_DATE;")); Link to comment https://forums.phpfreaks.com/topic/155385-records-from-todays-date/#findComment-817578 Share on other sites More sharing options...
PFMaBiSmAd Posted April 23, 2009 Share Posted April 23, 2009 If the date field is a datetime (with the time as part of the data), you would need to use the mysql DATE() function to get just the date part for the comparison - DATE(date) = CURDATE() Link to comment https://forums.phpfreaks.com/topic/155385-records-from-todays-date/#findComment-817596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.