You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more
If I want to test if a date/time is greater than 4am yesterday how would I go about doing it in sql?
check for anything greater than todays date Minus 20hrs
datediff maybe( not sure if that's t-sql specific)? Do you need to consider timezones at all?
to_char(start_date, 'YYYYMMDDHH24MISS') > to_ char(sysdate-1,'YYYYMMDD')||'040000'
works. I was sure I'd tried that before asking the question but must have had an error somewhere 🙂
easier:
your_date > DATEADD(hh, -20, CAST(CAST(GETDATE() AS DATE) AS DATETIME))
to_char(start_date, 'YYYYMMDDHH24MISS') > to_ char(sysdate-1,'YYYYMMDD')||'040000'
Hang on, did you just call to_char on every record in the table? this is a one off right?
/not an SQL guy
No use for Oracle though 🙂
ah, scope creep... 😆
Would something like this work?
create_date >= TO_DATE('28/01/2015 04:00:00.000000','MM/DD/YYYY HH24:MI:SS.FF')
/still not an SQL, let alone an oracle, guy
create_date >= CURRENT_DATE - INTERVAL '1 DAY' + INTERVAL '4 hours'