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 . "')) ";

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.