Addison, Mark wrote:

From: Chris W  Sent: 07 July 2006 09:23
It's late and I just gave up reading the manual. Can someone please tell me the easiest way to do a query that will return all rows with a time stamp that is X number of seconds older than the current time? Something like this.....

SELECT * FROM t
WHERE TimeCol < (now() - 60*60*24*3)

Yes I know that is just 3 days but other times I will want to find records that are a few hours old so I like using the formula.

SELECT * FROM t
WHERE TimeCol < DATE_SUB(CURDATE(), INTERVAL 60*60*24*3 SECOND);

Maybe it was just too late at night but I read about the DATE_SUB function in the manual and got the impression that it ignored the time part of a date time field so I could not use it for finding records only a few hours old.

--
Chris W
KE5GIX

Gift Giving Made Easy
Get the gifts you want & give the gifts they want One stop wish list for any gift, from anywhere, for any occasion!
http://thewishzone.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to