Official Content

Adds a given number of years to a given date.

Syntax

Date | DateTime.AddYears(Numeric-expression)

Where:

Date | DateTime
     
Is an attribute or variable based on the Date/DateTime data type, to which the method will add a certain number of years.

Numeric-expression
     Is a Numeric expression that indicates the number of years to be added to the Date | DateTime. 

Type returned:
Date | DateTime

Scope

Data Types: DateDateTime

Description

Returns a value which results from adding a number of years to a given date or date with time.

The result's data type will be the same as the given original value (Date or DateTime).

If the numeric expression is negative, the years are subtracted from the given date.

Samples

If &Today.Month() = 12
   &ExpiryDate = &Today.AddYears(1)
EndIf   

See Also

AddYr function
AddMonths method
AddDays method







Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant