Quote:
Originally posted by jahelstedt
I have a report that could be ran automatically everyday if I could figure out how to have SQL query one day before today.
Any thoughts?
|
SYSDATE - 1 RETURNS YESTERDAY'S DATE, AT SAME TIME.
TRUNC(SYSDATE - 1) RETURNS YESTERDAY'S DATE, WITHOUT TIME PART (I.E. MIDNIGHT)
SQL> alter session set nls_date_format = 'DD.MM.YYYY HH24:MI

S';
Session altered.
SQL> select sysdate from dual;
SYSDATE
-------------------
21.11.2003 08:32:35
SQL> select sysdate - 1 from dual;
SYSDATE-1
-------------------
20.11.2003 08:32:43
SQL> select trunc(sysdate-1) from dual;
TRUNC(SYSDATE-1)
-------------------
20.11.2003 00:00:00