Mr Chris Posted December 8, 2009 Share Posted December 8, 2009 Hello, Wondering if anyone can help me with a query. Basically I have a list of last_updated dates in my table 2009-12-06 09:40:00 2009-12-04 09:42:00 2009-12-06 09:44:00 And I want to say select all of these records where last_updated is not in the last 2 days from the current date and time? SELECT last_updated from tbl WHERE last_updated BETWEEN CURRENT_DATE AND CURRENT_DATE - INTERVAL 2 DAY Anyone help? Thanks Link to comment https://forums.phpfreaks.com/topic/184375-all-records-within-a-set-time-period/ Share on other sites More sharing options...
cags Posted December 8, 2009 Share Posted December 8, 2009 I've never really done much with DATETIME's in MySQL, but surely your code should be along the lines of... last_updated IS NOT BETWEEN ...or possibly... last_updated < CURRENT_DATE - INTERVAL 2 DAY Link to comment https://forums.phpfreaks.com/topic/184375-all-records-within-a-set-time-period/#findComment-973342 Share on other sites More sharing options...
mwasif Posted December 8, 2009 Share Posted December 8, 2009 Try this one SELECT last_updated from tbl WHERE last_updated > DATE_SUB(NOW(), INTERVAL 2 DAY) Link to comment https://forums.phpfreaks.com/topic/184375-all-records-within-a-set-time-period/#findComment-973563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.