Official Content

Calculates the difference in years between two date expressions.

Syntax

Date1 | DateTime1 .Age([ ,Date2 | DateTime2 ])

Type Returned:
Numeric N(4)

Scope

Data Types: DateDateTime
Generators: .NET, Java, RPG, Cobol, Visual FoxPro (up to GeneXus X Evolution 3), Ruby (up to GeneXus X Evolution 3)

Description

This method returns the difference in years between the two parameters (second parameter - first parameter).

The second parameter is optional. If it is omitted, the default value depends on the first parameter’s data type:

1.  if it is of Date type, the default value is the one returned by the Today function.
2.  if it is of DateTime type, the default value is the one returned by the Now function.

If the first parameter is less than the second parameter, the Age function returns a positive value. Otherwise, it returns a negative value.

Samples

&Nbr = &DateOfBirth.Age()

See Also

Age function


 


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