timmah1 Posted November 6, 2011 Share Posted November 6, 2011 Why is this not working? $result = mysql_query("SELECT * FROM contacts WHERE type = 'consumer' AND sent BETWEEN '".date("Y-m-d")."' AND '".date("Y-m-d", strtotime("-7 days"))."'") or die(mysql_error()); $numrows = mysql_num_rows($result); if($numrows < 0 ){ echo "No records found"; } The record that is stored in the sent column is like this "2011-11-03 14:42:12", so there is a record in there, but nothing is showing up. Can anyone see why? thanks in advance Link to comment https://forums.phpfreaks.com/topic/250573-between-date-range/ Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 You need the smaller date first. http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between Link to comment https://forums.phpfreaks.com/topic/250573-between-date-range/#findComment-1285685 Share on other sites More sharing options...
timmah1 Posted November 6, 2011 Author Share Posted November 6, 2011 Oh geesh. Thanx. I knew it'd probably be something simple. Link to comment https://forums.phpfreaks.com/topic/250573-between-date-range/#findComment-1285686 Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 Always check the manual first Link to comment https://forums.phpfreaks.com/topic/250573-between-date-range/#findComment-1285687 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.