Is this possible, and if so, how do I get this working?

If datetime from table is greater than another datetime from table, then run query.


so pretend its:

$date1 = $row["date1"]; (june 19th) (i have a query on the page were it updates the day everytime you visit, NOW())

$date2 = $row["date2"]; (june 20th)


if ($date1 > $date 2) {
RUN QUERY; }


But that above statement isn't working.


if anyone could help, thanks.

Hi griffith,

You are trying to do a numerical comparison of strings that contain words. Try storing the date in the database in a date format (YYYYMMDD) so June 19th 2010 will be 20100619. Your comparisons should work then.

Hope this helps.
Zagga

In the MySQL table, how do you make it YYYYMMDD?

Field
Type <<< I don't see date format YYYYMMDD in the type drop down menu
Length/Values
Default
Collation

etc

type = "date".

:)

This will store the date as YYYY-MM-DD.
You can then strip out the "-" seperators and compare the dates

$date1 = str_replace("-", "", $date1);
$date2 = str_replace("-", "", $date2);
If($date1 > $date2){
   run your query here;
}