Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple intervals to Date_Add

I want to add 2 months and 2 years to the current date but for some reason i cannot get it to work.

 Select DATE_ADD(NOW(), INTERVAL 2 MONTH, INTERVAL 2 YEAR);
like image 432
hue manny Avatar asked Oct 26 '14 02:10

hue manny


2 Answers

You could also just use addition

SELECT NOW() + INTERVAL 2 YEAR + INTERVAL 2 MONTH
like image 132
Ozzy Avatar answered Sep 28 '22 08:09

Ozzy


Try using date_add() twice:

Select DATE_ADD(DATE_ADD(NOW(), INTERVAL 2 MONTH), INTERVAL 2 YEAR);

Or once:

Select DATE_ADD(NOW(), INTERVAL 14 MONTH);
like image 40
Gordon Linoff Avatar answered Sep 28 '22 07:09

Gordon Linoff