Oracle get previous day records

Posted by Phill Pafford on Stack Overflow See other posts from Stack Overflow or by Phill Pafford
Published on 2010-03-31T18:18:04Z Indexed on 2010/03/31 18:23 UTC
Read the original article Hit count: 330

Filed under:
|
|

Ok I think I'm getting the previous year instead of the previous day, but I need to previous day.

SELECT TO_DATE(TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD'),'YYYY-MM-DD') - 1 FROM Dual

I'm comparing it to a datetime stamp in this format and wish to get all the rows from the previous day.

YYYY-MM-DD HH:MM:SS

So I'm trying something like this

SELECT field,datetime_field 
FROM database
WHERE datetime_field > TO_DATE(TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD'),'YYYY-MM-DD') - 1

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about datetime