Skip to main content
Solved

Add months and subtract days

  • November 16, 2019
  • 2 replies
  • 83 views

Hi, just started using Airtable and I think it’s great. I was wondering if it’s possible to use the DATEADD() function to add a set number of months and subtract a set number of days in the same formula. I realise I could create two fields, one with DATEADD() for the months and a second with DATEADD() to subtract the days but just wondering if there’s a more elegant solution?

Any help would be appreciated.

Thanks

Best answer by AlliAlosa

Hi there, James! Welcome to the community!

You can absolutely do this. Let’s say we want to add one month, and subtract one day. I would write the formula like this:

IF({Date}, DATEADD(DATEADD({Date}, 1, 'month'), -1, 'day'))

If {Date} were today, 11/17/2019, the above would give us a result of 12/16/2019.

You could write this without wrapping it in the IF() statement, but I recommend using it to avoid getting #ERROR! when the field {Date} is empty :slightly_smiling_face:

2 replies

Forum|alt.badge.img+19
  • Inspiring
  • Answer
  • November 17, 2019

Hi there, James! Welcome to the community!

You can absolutely do this. Let’s say we want to add one month, and subtract one day. I would write the formula like this:

IF({Date}, DATEADD(DATEADD({Date}, 1, 'month'), -1, 'day'))

If {Date} were today, 11/17/2019, the above would give us a result of 12/16/2019.

You could write this without wrapping it in the IF() statement, but I recommend using it to avoid getting #ERROR! when the field {Date} is empty :slightly_smiling_face:


  • Author
  • Participating Frequently
  • November 18, 2019

Hi there, James! Welcome to the community!

You can absolutely do this. Let’s say we want to add one month, and subtract one day. I would write the formula like this:

IF({Date}, DATEADD(DATEADD({Date}, 1, 'month'), -1, 'day'))

If {Date} were today, 11/17/2019, the above would give us a result of 12/16/2019.

You could write this without wrapping it in the IF() statement, but I recommend using it to avoid getting #ERROR! when the field {Date} is empty :slightly_smiling_face:


That’s great, thanks!