Date.AddYears
Adds the specified years to the date.
Syntax
Date.AddYears(
dateTime as any,
numberOfYears as number
) as any
Remarks
Returns the date
, datetime
, or datetimezone
result of adding numberOfYears
to a datetime
value dateTime
.
dateTime
: Thedate
,datetime
, ordatetimezone
value to which years are added.numberOfYears
: The number of years to add.
Examples
Example #1
Add 4 years to the <code>date</code>, <code>datetime</code>, or <code>datetimezone</code> value representing the date 5/14/2011.
Date.AddYears(#date(2011, 5, 14), 4)
Result:
#date(2015, 5, 14)
Example #2
Add 10 years to the <code>date</code>, <code>datetime</code>, or <code>datetimezone</code> value representing the date and time of 5/14/2011 08:15:22 AM.
Date.AddYears(#datetime(2011, 5, 14, 8, 15, 22), 10)
Result:
#datetime(2021, 5, 14, 8, 15, 22)
Category
Date