Help

Re: Add or subtract years in a date

Solved
Jump to Solution
4013 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Lynda_Stringer
6 - Interface Innovator
6 - Interface Innovator

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.

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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.

See Solution in Thread

5 Replies 5
kuovonne
18 - Pluto
18 - Pluto

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.

Lynda_Stringer
6 - Interface Innovator
6 - Interface Innovator

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?

Lynda_Stringer
6 - Interface Innovator
6 - Interface Innovator

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’)

Lynda_Stringer
6 - Interface Innovator
6 - Interface Innovator

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

DavidMillanP
4 - Data Explorer
4 - Data Explorer

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.