3raser Posted November 5, 2012 Share Posted November 5, 2012 I have several units (days, weeks, years) I'd like to add to the current date in MySQL. How would I go about doing this? I tried: ADDDATE(CURRENT_DATE(), INTERVAL {$length[0]} YEAR INTERVAL {$length[1]} MONTH INTERVAL {$length[2]} WEEK INTERVAL {$length[3]} DAY) But doesn't work. Can you even add multiple intervals? Link to comment https://forums.phpfreaks.com/topic/270336-how-would-i-go-about-adding-to-the-current-date-in-mysql/ Share on other sites More sharing options...
Barand Posted November 5, 2012 Share Posted November 5, 2012 mysql> SELECT CURDATE() + INTERVAL 1 YEAR + INTERVAL 1 MONTH + INTERVAL 1 DAY as newdate; +------------+ | newdate | +------------+ | 2013-12-06 | +------------+ Link to comment https://forums.phpfreaks.com/topic/270336-how-would-i-go-about-adding-to-the-current-date-in-mysql/#findComment-1390431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.