How can I select records ONLY from yesterday?

Viewed 195149

I've spent hours searching the web for an answer to this question...

Here's what I currently have:

select  *
from    order_header oh
where   tran_date = sysdate-1
6 Answers

This comment is for readers who have found this entry but are using mysql instead of oracle! on mysql you can do the following: Today

SELECT  * 
FROM 
WHERE date(tran_date) = CURRENT_DATE()

Yesterday

SELECT  * 
FROM yourtable 
WHERE date(tran_date) = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)

If you want the timestamp for yesterday try something like:

(CURRENT_TIMESTAMP - INTERVAL '1' DAY)
Related