「MySQL入門」日時の計算(加算、減算)サンプル
1.[1日前]
select subdate(“2014-09-20 18:21:05″, interval 1 day); //"2014-09-19 18:21:05"
select “2014-09-20 18:21:05" – interval 1 day;
2.[1月前]
subdate(“2014-09-20 18:21:05″, interval 1 month); //"2014-08-20 18:21:05"
select “2014-09-20 18:21:05" – interval 1 month;
3.[1日後]
select adddate(“2014-09-20 18:21:05″, interval 1 day); //"2014-09-21 18:21:05"
select “2014-09-20 18:21:05" + interval 1 day;
4.[1月後]
select adddate(“2014-09-20 18:21:05", interval 1 month); //"2014-10-20 18:21:05″select “2014-09-20 18:21:05" + interval 1 month;