获取日期中的年,月,日
SQL> select EXTRACT (DAY FROM SYSDATE) from dual;
EXTRACT(DAYFROMSYSDATE)
-----------------------
18
SQL> select extract (year from sysdate) from dual;
EXTRACT(YEARFROMSYSDATE)
------------------------
2016
SQL> select extract(month from sysdate) from dual;
EXTRACT(MONTHFROMSYSDATE)
-------------------------
1
获取月的第一天
SQL> select trunc(sysdate,'MM') from dual;
TRUNC(SYSDATE,'MM')
-------------------
2016/1/1
获取季度的第一天
SQL> select trunc(sysdate,'Q') from dual;
TRUNC(SYSDATE,'Q')
------------------
2016/1/1
获取年的第一天
SQL> select trunc(sysdate,'Y') from dual;
TRUNC(SYSDATE,'Y')
------------------
2016/1/1
查看前一个小时
select sysdate-1/24 from dual;
查看前10秒钟
select sysdate + 10/(60*60*24) from dual;
加一个月
SQL> select add_months(sysdate,1) from dual;
ADD_MONTHS(SYSDATE,1)
---------------------
2016/2/18 19:11:51
减3个月
SQL> select add_months(sysdate,-3) from dual;
ADD_MONTHS(SYSDATE,-3)
----------------------
2015/10/18 19:12:20
查看下一个星期六是几号
SQL> select NEXT_DAY (SYSDATE, 'SATURDAY') from dual;
NEXT_DAY(SYSDATE,'SATURDAY')
----------------------------
2016/1/23 19:13:26