interval
示例:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') currenttime,
to_char(sysdate - interval '7' year,'yyyy-mm-dd hh24:mi:ss') intervalyear,
to_char(sysdate - interval '7' month,'yyyy-mm-dd hh24:mi:ss') intervalMonth,
to_char(sysdate - interval '7' day,'yyyy-mm-dd hh24:mi:ss') intervalday,
to_char(sysdate - interval '7' hour,'yyyy-mm-dd hh24:mi:ss') intervalHour,
to_char(sysdate - interval '7' minute,'yyyy-mm-dd hh24:mi:ss') intervalMinute,
to_char(sysdate - interval '7' second,'yyyy-mm-dd hh24:mi:ss') intervalSecond
from dual;
add_months
示例:
select add_months(sysdate,1) newtime from dual;
months_between
示例:
select months_between(to_date('03-31-2015','MM-DD-YYYY'),to_date('12-31-2014','MM-DD-YYYY')) "MONTHS" FROM DUAL;
next_day
示例:
select sysdate today, next_day(sysdate,6) the_week from dual;
to_date
示例:
select to_date('2009-07-04 05:02:01','yyyy-mm-dd hh24:mi:ss') the_time from dual;
to_char
示例:
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') the_time,
to_char(sysdate,'yyyy') the_year,
to_char(sysdate,'mm') the_month,
to_char(sysdate,'dd') the_day,
to_char(sysdate,'day') the_week,
to_char(sysdate,'hh24')the_hour,
to_char(sysdate,'mi') the_minute,
to_char(sysdate,'ss') the_second
from dual;