From: "shaun thornburgh" > I have a DATETIME COLUMN in my table and i need to be able to perform an > update on all colmns that are 48 hours old as specified in that column. As I > am using 4.0.17 I am unable to use the TIME() functions, is there another > way to do this?
I tend to use constructions such as: ... WHERE `col_datetime` < NOW() - INTERVAL 2 DAY; ... WHERE `col_datetime` > NOW() - INTERVAL 48 HOUR AND `col_datetime` < CURDATE() + INTERVAL 7 DAY; MySQL will calculate the expression and turn it into a constant before the query is executed, so you'll end up with a simple column < constant type expression (which can use indexes efficiently). NOW() will give you the datetime of this moment, while CURDATE() will give you the datetime of today at midnight. For more INTERVAL options see: http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html in the text about the DATE_ADD function. Regards, Jigal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]