0

Hey.

Could someone assist me here please. In my SQL code, I have to select dates greater/less/equal to a date posted, but I need assistance with this, since, if you check out the coding below, you will see (I guess so) that PHP will regard the input as just numbers or values but not as dates? I'd like to search for the dates specified by my field post. And the way it is right now, well I think this is not the way to do it.

Guess I hace to convert the dates? No clue.

$alpha = "2008-08-29 07:00:00";
	$omega = "2008-09-10 07:00:00";

	$sql  = "SELECT DISTINCT items.room_id ";
	$sql .= "FROM bookings INNER JOIN items ON bookings.room_id = items.room_id ";
	$sql .= "WHERE ((bookings.book_end > '" . $alpha . "' ";
	$sql .= "AND bookings.book_end <= '" . $omega . "') ";
	$sql .= "OR (bookings.book_start < '" . $omega . "' ";
	$sql .= "AND bookings.book_start >= '" . $alpha . "') ";
	$sql .= "OR (bookings.book_start <= '" . $alpha . "' ";
	$sql .= "AND bookings.book_end >= '" . $omega . "')) ";
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by architact
0

Insted of actual date format use timestamp format returned by php time() function. Then you will be able to use >, < and equal to.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.