select sysdate 当前时间,
sysdate + 1 加一天,
sysdate - 1 减一天,
sysdate + (1 / 24) 加一小时,
sysdate + (1 / 24 / 60) 加一分钟,
sysdate + (1 / 24 / 60 / 60) 加一秒钟
from dual;
select sysdate 当前时间,
add_months(sysdate, 1) 加一月,
add_months(sysdate, - 1) 减一月,
add_months(sysdate, 1 * 12) 加一年
from dual;
select sysdate as 当前时间,
sysdate + interval '1' year as 加一年,
sysdate + interval '-1' year as 减一年,
sysdate + interval '1' month as 加一月,
sysdate + interval '1' day as 加一天,
sysdate + interval '1' hour as 加一小时,
sysdate + interval '1' minute as 加一分钟,
sysdate + interval '1' second as 加一秒
from dual;
interval() 函数的语法
interval ‘时间差数值’ { year | month | day | hour | minute | secode} (精度数值)
精度数值范围是 1-9,默认值是 2
select sysdate + interval '123' year from dual;
--此时,‘123’ 为 3 位有效数值,该处 year(n), n < 3 就会报错,而 n默认 是 2
select sysdate + interval '111' year(3) from dual;