0

I am working in mysql database, and I have a table called bookings in that two columns named start_date and end_date And I get a date value from my php script

Can anybody tell me how can I check that date is in between those start_date and end_date

I have tried this:

mysql_query("SELECT * FROM `tbl_booking` WHERE '$date' between Start_date AND end_date");
jpcanamaque
  • 1,049
  • 1
  • 8
  • 14

2 Answers2

0

BETWEEN assumes that you have some values and comparing column with them. I believe it should be something like: WHERE Date(start_date) <= '$date' AND Date(end_date) >= '$date'

PS: Not sure about PHP's var interpolation though. Added typecast from one of answers, that seems to be correct.

Ivan Yurov
  • 1,578
  • 10
  • 27
0

if you have column type Date then try

mysql_query("SELECT * FROM tbl_booking WHERE date_column between Start_date AND end_date");

if Datetime then

mysql_query("SELECT * FROM tbl_booking WHERE Date(date_column) between Start_date AND end_date");
Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44