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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 Always check the manual first Quote Link to comment 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.