Nov 16, 2019 01:48 AM
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
Solved! Go to Solution.
Nov 17, 2019 09:30 AM
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:
Nov 17, 2019 09:30 AM
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:
Nov 17, 2019 11:07 PM
That’s great, thanks!