oracle
add_months(日期格式值 , 整数n) 当整数n=12时,代表一年,向后推迟一年,若n=-12代表回退一年
如
to_char(add_months(to_date('201801'),12),'yyyyMM' ) 结果:201901
to_char(add_months(to_date('201801'),-12),'yyyyMM') 结果:201701
mysql
adddate(日期格式 ,INTERVAL 值n 时间类型)
值n:可正可负
时间类型:
SECOND
MINUTEHOURDAYWEEKMONTHQUARTERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTHselect adddate(str_to_date('20190226','%Y%m%d') ,INTERVAL -12 MONTH) from dual 结果:2018-02-26
select adddate(str_to_date('20190226','%Y%m%d') ,INTERVAL 12 MONTH) from dual 结果:2020-02-26
如:
select date_add('2019-02-26 23:59:59',INTERVAL '1:1' HOUR_MINUTE); 结果:2019-02-27 01:00:59