Skip to main content
Solved

Add or subtract years in a date

  • Jul 22, 2020 3:36 PM UTC
  • 5 replies
  • 307 views

Forum|alt.badge.img+1

I have a date in CurDt and I want to add YrOffset to it and end up with a new date in a date format. YrOffset can be negative, positive or 0. I’m not sure how to do it.

Best answer by kuovonne

Use the DATEADD([date], [#], 'units') formula function with 'years' as the units.

To add one year

DATEADD({Date Field}, 1, 'years')

To subtract one year

DATEADD({Date Field}, -1, 'years')

It is documented in the formula field reference.

View original
This topic has been closed for replies.

5 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • Answer
  • Jul 22, 2020 4:06 PM UTC

Use the DATEADD([date], [#], 'units') formula function with 'years' as the units.

To add one year

DATEADD({Date Field}, 1, 'years')

To subtract one year

DATEADD({Date Field}, -1, 'years')

It is documented in the formula field reference.


Forum|alt.badge.img+1
  • Author
  • Known Participant
  • Jul 22, 2020 5:55 PM UTC

It worked except is added the time into the field. How do I get rid of the time and keep the date in a date format?


Forum|alt.badge.img+1
  • Author
  • Known Participant
  • Jul 22, 2020 11:02 PM UTC

I figured out how to get rid of the time, but when I try to convert back to date format it adds the time back. Here is what I have right now:
DATETIME_FORMAT(DATEADD({Cur GM Yr},yrOffset,‘years’),‘MM/DD/YYYY’)


Forum|alt.badge.img+1
  • Author
  • Known Participant
  • Jul 23, 2020 8:11 AM UTC

I figured out on the formatting setting I could tell it not to include the time.


Forum|alt.badge.img+3
  • New Participant
  • Aug 2, 2023 11:48 PM UTC

Thank you Kuovonne! Does anyone know how I can do this in an automation? I want to add 1 year to the date in a record when that record matches certain conditions. I appreciate your help.