Jump to content

[SOLVED] SQL date problem


gerkintrigg

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.