nevadasam — 2010-05-11T22:28:44-04:00 — #1
I want to select all records that have been updated in the last 12 hours.
My database contains this field to record the time of update: lastdatetime, type = datetime
so the time updated would be recorded as: 2010-05-11 21:54:03
This is my current WHERE claus
[B]WHERE TO_DAYS( NOW( ) ) - TO_DAYS( lastdatetime ) <=1 AND DATE_FORMAT( CURRENT_TIMESTAMP( ) , '%H%i' ) - DATE_FORMAT( lastdatetime, '%H%i' ) <=720[/B]
I got this ideal from a post on dev.mysql.com. It is suppose to "filter for 1 day or less since updated. After that, it filters for 720 minutes (12 hurs) or less since updated".
sjh — 2010-05-12T03:56:30-04:00 — #2
WHERE lastdatetime >= CURRENT_TIMESTAMP - INTERVAL '12' HOUR
sjh — 2010-05-12T06:04:42-04:00 — #3
Hold on, that will only work for MySQL...
r937 — 2010-05-12T06:19:54-04:00 — #4
luckily that's what he's using -- TO_DAYS and DATE_FORMAT are mysql functions
sjh — 2010-05-12T08:31:49-04:00 — #5