1、SYSDATE
SELECT
SYSDATE+3 三天后的日期,
SYSDATE-3 三天前的日期
FROM dual;
2、ADD_MONTHS
SELECT
ADD_MONTHS(SYSDATE,3) 三个月后的日期,
ADD_MONTHS(SYSDATE,-3) 三个月之前的日期
FROM dual;
3、NEXT_DAY
SELECT
NEXT_DAY(SYSDATE,'星期日') 下一个星期日,
NEXT_DAY(SYSDATE, '星期一') 下一个星期一
FROM dual;
4、LAST_DAY
SELECT
LAST_DAY(SYSDATE) 最后一天
FROM dual;
5、MONTH_BETWEEN () 取得两个日期所经过的月份
SELECT
MONTH_BETWEEN(SYSDATE,hiredate)
FROM emp;
6、EXTRACT()提取年月日
SELECT
EXTRACT(YEAR FROM DATE '2018-05'-22) years,
EXTRACT(MONTH FROM DATE '2018-05'-22) months,
EXTRACT(DAY FROM DATE '2018-05'-22) days
FROM dual;
2018 05 22
或者
SELECT
EXTRACT(YEAR FROM SYSTIMESTAMP) years,
EXTRACT(MONTH FROM SYSTIMESTAMP) months,
EXTRACT(HOUR FROM SYSTIMESTAMP) hour,
EXTRACT(SEOND FROM SYSTIMESTAMP ) second
FROM dual;