tags:

views:

149

answers:

4
$Date = date("m/d/Y");
$result = mysql_query("SELECT * FROM service WHERE SType = 'Retreat' and Start_date > '$Date' ");

Start_date format is m/d/y also.

whats wrong with my code? all i want to do is to display all the possible data greater than the current date. but it always show all the data from the database.

A: 

Have you looked at this: http://www.bigroom.co.uk/blog/dates-in-php-and-mysql ?

The article suggests you consider doing something like

$result = mysql_query("SELECT * FROM service WHERE SType = 'Retreat' and Start_date > FROM_UNIXTIME($Date) ");

Jack
A: 

It's best if you use the YYYY-MM-DD format for dates in MySQL.

cherouvim
+2  A: 

Use date("Y-m-d") rather than date("m/d/Y").

MiseryIndex
A: 

It depends on how you store your date. If its stored as a unixtime, then you simply do an equal or greater check and you are on your way.

PHP has some great functions to turn date into unixtime. Like strtotime

Ólafur Waage