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. Link to comment https://forums.phpfreaks.com/topic/60287-solved-mysql-between/ 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"? Link to comment https://forums.phpfreaks.com/topic/60287-solved-mysql-between/#findComment-299866 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 Link to comment https://forums.phpfreaks.com/topic/60287-solved-mysql-between/#findComment-299867 Share on other sites More sharing options...
suttercain Posted July 16, 2007 Author Share Posted July 16, 2007 that worked Barrand. Thanks! Link to comment https://forums.phpfreaks.com/topic/60287-solved-mysql-between/#findComment-299868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.