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
Thanks in advance.
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
Thanks in advance.
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
Yesterday
Use:
Reference: TRUNC
Calling a function on the
tran_date
means the optimizer won't be able to use an index (assuming one exists) associated with it. Some databases, such as Oracle, support function based indexes which allow for performing functions on the data to minimize impact in such situations, but IME DBAs won't allow these. And I agree - they aren't really necessary in this instance.If you don't support future dated transactions then something like this might work:
If you want the timestamp for yesterday try something like: