NUMTODSINTERVAL
numtodsinterval(
teledb=# select sysdate,sysdate+numtodsinterval(2,'hour') as res from dual;
orcl_sysdate | res
----------------------------+----------------------------
2023-08-24 10:49:53.417051 | 2023-08-24 12:49:53.417051
(1 row)
teledb=#
DBTIMEZONE
teledb=# select DBTIMEZONE from dual;
dbtimezone
------------
08:00:00
(1 row)
teledb=#
MONTHS_BETWEEN
teledb=# select months_between(to_date('20210331', 'yyyymmdd'), to_date('20200131', 'yyyymmdd')) as months from dual;
months
--------
14
(1 row)
teledb=#
LAST_DAY
LAST_DAY函数返回指定日期对应月份的最后一天。
teledb=# SELECT last_day('2020-05-01') FROM dual;
last_day
------------------------
2020-05-31 00:00:00+08
(1 row)
teledb=#
ADD_MONTHS
ADD_MONTHS(x,y)
x值为日期,y值为数量,用于计算某个日期向前或者向后y个月后的时间。
teledb=# select add_months(sysdate,1) from dual;
add_months
----------------------------
2023-09-24 11:08:17.194487
(1 row)
teledb=# select add_months(sysdate,-1) from dual;
add_months
----------------------------
2023-07-24 11:08:21.019573
(1 row)
teledb=#