1、加天数的方法,直接在日期后面加上天数就行了,例如:
select sysdate+N from dual;
可以引申出加小时、分钟等,例如
select sysdate+1/24 from dual;//加1个小时
2、加月数、年数,可以使用add_months();
select sysdate,add_months(sysdate,2) from dual;//加2个月
同理select sysdate,add_months(sysdate,12) from dual;//加一年
开发过程中有时比较复杂,我实际开发过程中要求加的年数、月数、天数是通过xx-xx-xx格式来确定的,例如02-03-12,及加2年2个月12天,这时就还需要去拆分了,例如ymd字段表示的就是xx-xx-xx格式
select case when ymd!='00-00-00' then add_months(add_months(date+to_number(substr(ymd,7,2)),to_number(substr(ymd,4,2))),to_number(substr(ymd,1,2))*12) end as newymd from table_name;