码迷,mamicode.com
首页 > 数据库 > 详细

oracle 时间

时间:2018-01-02 11:43:33      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:font   log   blog   sel   sele   nbsp   rom   col   char   

select to_char(to_date(sysdate,yyyy-mm-dd),day) from dual;

select to_date(2017-12-31,day) from dual;

select sysdate,to_char(sysdate,yyyy-mm-dd hh24:mi:ss) from dual;   
select sysdate,to_char(sysdate,yyyy-mm-dd hh:mi:ss) from dual;   
select sysdate,to_char(sysdate,yyyy-ddd hh:mi:ss) from dual;   
select sysdate,to_char(sysdate,yyyy-mm iw-d hh:mi:ss) from dual;   
    

select TO_CHAR(SYSDATE,YYYYMMDD) res from dual;

select TRUNC(LAST_DAY(SYSDATE))+1 res from dual;


select TO_CHAR(TRUNC(sysdate) + 3,YYYYMMDD) res from dual;

select to_date(1996,yyyy) - to_date(1995,yyyy)  from dual;
select to_date(1995,yyyy) - to_date(1994,yyyy)  from dual;  
select to_date(2008,yyyy) - to_date(2007,yyyy)  from dual;
select to_date(2000,yyyy) - to_date(1999,yyyy)  from dual;
select to_date(2004,yyyy) - to_date(2003,yyyy)  from dual;
select to_date(2020,yyyy) - to_date(2019,yyyy)  from dual;
select to_date(sysdate,yyyy) - to_date(sysdate,yyyy) -1  from dual;

select ADD_MONTHS(trunc(sysdate,yyyy),12) from dual;

select to_date(to_char(ADD_MONTHS(trunc(sysdate,yyyy),12)),RRRR) from dual;

select TO_CHAR(SYSDATE,RRRR) + 1 from dual;

select to_date(TO_CHAR(SYSDATE,RRRR),yyyy) - to_date(TO_CHAR(SYSDATE,RRRR)-1,yyyy)  from dual;

select * from ADD_MONTHS(trunc(sysdate,yyyy),12)+2/24 from dual;

select TO_CHAR(2017-12-29,DAY) from dual;

--当前的年月日20171231
select TO_CHAR(TRUNC(sysdate) + 3,YYYYMMDD) res from dual;

select TO_CHAR(TRUNC(sysdate) + 3,DS) res from dual;

select to_char(to_date(TRUNC(sysdate),yyyy-mm-dd),d) from dual;

select to_char(to_date(TRUNC(sysdate),yyyy-mm-dd),IW) from dual;

 

oracle 时间

标签:font   log   blog   sel   sele   nbsp   rom   col   char   

原文地址:https://www.cnblogs.com/520future/p/8175570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!