Oracle 日期处理

select * from dt where dw_data=to_date(to_char(sysdate-1,'YYYY-MM-DD'),'YYYY-MM-DD')  ---取前一天日期


SQL>  select * from dt where dw_data=trunc(sysdate-1,'dd');

DW_DATA
---------
25-DEC-00


SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
SQL> select trunc(sysdate) from dual; 

TRUNC(SYSDATE)
-------------------
2000-12-26 00:00:00



SQL> select trunc(sysdate,'dd') from dual;

TRUNC(SYSDATE,'DD')
-------------------
2000-12-26 00:00:00



SQL>  select sysdate from dual;

SYSDATE
-------------------
2000-12-26 19:42:39



SQL> select * from dt;

DW_DATA
-------------------
2000-12-25 00:00:00

posted @ 2014-01-02 11:03  czcb  阅读(202)  评论(0编辑  收藏  举报