gerkintrigg Posted March 15, 2007 Share Posted March 15, 2007 I'm trying to use the following code to check whether a property is booked. Could you please let me know if it's right? $check_availability="SELECT COUNT(*) AS records FROM booking WHERE ".date('Y-m-d',$start_date)." BETWEEN start_date && end_date;"; echo $check_availability; The query outputs this: SELECT COUNT(*) AS records FROM booking WHERE 2007-03-10 BETWEEN start_date && end_date; which is fine, but the problem is that I keep getting a zero when I run it in PHPMyAdmin. Whereas I know there should be two records found. Can anyone suggest any remedy? Thanks, Neil Link to comment https://forums.phpfreaks.com/topic/42821-solved-sql-date-problem/ Share on other sites More sharing options...
o3d Posted March 15, 2007 Share Posted March 15, 2007 Your query should read something like this : SELECT COUNT(*) AS records FROM booking WHERE '2007-03-10' BETWEEN start_date AND end_date Link to comment https://forums.phpfreaks.com/topic/42821-solved-sql-date-problem/#findComment-207886 Share on other sites More sharing options...
gerkintrigg Posted March 15, 2007 Author Share Posted March 15, 2007 Thanks... i think it was just the quotes. Link to comment https://forums.phpfreaks.com/topic/42821-solved-sql-date-problem/#findComment-207908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.