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 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php