Re: TIMESTAMP and COMPARISON

From: Date: Wed, 20 Mar 2002 20:16:20 +0000
Subject: Re: TIMESTAMP and COMPARISON
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-89398@lists.php.net to get a copy of this message
On Thursday 21 March 2002 03:53, chris allen wrote: > Hello, > > > I am looking for a standard way to compare to dates. I have a date/time > stored in a field in a mysql table as > date_added TIMESTAMP(14)..... (IE yyyymmddhhmmss). > > I want to delete all records in this table if date_added is older than 2 > hours. > > IE > if current_date > date_added +2 hours then delete record. > > How do I do this from within mysql? There are plenty of date/time functions in MySQL -- DATE_ADD(), DATE_SUB() etc. For example: DELETE FROM table WHERE current_date > DATE_ADD(date_added, INTERVAL 2 HOUR); **Untested** use with caution. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* You cannot have a science without measurement. -- R. W. Hamming */

« previous php.general (#89398) next »