suttercain Posted July 16, 2007 Share Posted July 16, 2007 Hi guys, I am trying to select BETWEEN two dates: <?php $date1 = mysql_real_escape_string($_GET['input9']); $date2 = mysql_real_escape_string($_GET['input10']); echo $date1 ." & ". $date2; $query = mysql_query("SELECT * FROM canada WHERE letter_requested BETWEEN $date1 AND $date2") or die (mysql_error()); while($row = mysql_fetch_array($query)) { echo $row['first_name']; } ?> I am not getting any out put. But if I run just "SELECT * FROM canada" I do get the out put. Am i using the BETWEEN correctly? Thanks. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 16, 2007 Share Posted July 16, 2007 You need to put $date1 and $date2 in single quotes. What format are your dates, and "letter_requested"? Quote Link to comment Share on other sites More sharing options...
suttercain Posted July 16, 2007 Author Share Posted July 16, 2007 They are in typical MySQL date format YYYY-MM-DD Quote Link to comment Share on other sites More sharing options...
suttercain Posted July 16, 2007 Author Share Posted July 16, 2007 that worked Barrand. Thanks! 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.