Adding Months to Dates

Have you ever found a formula that you’ve needed and looked for and somehow overlooked repeatedly? Yeah. If you are trying to add months to a date and you’re frustrated with adding days() and duration() which adds more time rather than days, here’s your answer.

Straight out of the Coda Formulas page. I don’t know how I kept missing it. I created a very ugly formula to add months checking for end of year, end of month, etc. UGH! Glad to find this. Hopefully, no one overlooks it like I did!

RelativeDate(dateTime, months)

Copy link

Add months to a date/time

**RelativeDate**(Date(2016, 1, 1), 2)

3/1/2016

INPUTS

dateTime
A date/time
months
Months to add (can be negative)

OUTPUT

Outputs months added to dateTime rounded to the day.

8 Likes

THANK YOU FOR THIS. Saved me a ton of time. :pray:

You’re welcome. I know I was happy to find that formula. I just wish I had found it before I wasted so much time creating a formula to do the same thing. :slight_smile:

This is awesome. The documentation doesn’t fully describe how it works, however. What happens if you do RelativeDate(Date(2016, 1, 31), 1)? There’s no Feb 31 so what is the result?

Edit: It looks like the result of RelativeDate(Date(2016, 1, 31), 1) is 2/29/2016.