Adds the specified number of years to a date.This function takes a date, integer, and string value as arguments and returns a date value.
If the date is February 29 and is changed to a year that is not a leap year, the day of the month is decreased to a valid number. For example, if the original date is February 29, 2000, and one year is added to it, the returned date is February 28, 2001, because February has only 28 days in 2001.
DateAddYears(<date>, <years>, <time_zone>)
The date to add years to.
The number of years to add to the date.
(Optional) The time zone code. This argument specifies the time zone of the date. For example, if you want the date to be in Eastern Standard Time (EST), enter the time zone argument
"EST". If you do not specify a time zone, the local time zone of the user who is completing the form is used.
Assume that you have a form in which there is a date field question with the reference name date_to_shift, and a number field question with the reference name years_to_add. The user is in the EST time zone. In the number field, the user enters
10. In the date field, the user chooses the date January 31, 2000.
- The expression DateAddYears($date_to_shift, $years_to_add) returns a date value that represents January 31, 2010 12:00 AM EST.
- The expression DateAddYears($date_to_shift, $years_to_add, "PST") returns a date value that represents January 30, 2010 9:00 PM EST.