Age
The age()
function allows you to easily calculate how long ago a date occurred
It finds the difference between a past date and today meaning that its use is not limited to the age of a person
The generic form is node.[DateProperty].age()
With no parameter entered within the ()
of age()
the results are returned as years however entering a unit within the bracket will return the result in the selected unit
The units supported are:
'd'
-> days'w'
-> weeks'm'
-> months'y'
-> years
Note: Parameters should be wrapped in
'
quotation marks within the()
Calculate age using date of birth
To calculate age for employees using their date of birth
node.dateofbirth.age()
So in this example node.dateofbirth.age()
returns the difference between the date of birth and today in years for a selected node
To return whole years only add .floor() to the expression
node.dateofbirth.age().floor()
Calculate weeks in role
To calculate the number of whole weeks in a role, insert the 'w'
parameter into the age()
expression
nodes.rolestartdate.age('w').floor()
Calculate average tenure
To calculate the average, minimum or maximum tenure of all employees in your organisation Aggregators may be used with the age()
function
nodes().RoleStartDate.age()
Yields the list of tenure values for the nodes (the number of years in current role)
To calculate this in months the 'm'
parameter should be entered
nodes().RoleStartDate.age('m')
Finally by adding .avg
at the end gives the average in months
nodes().rolestartdate.age('w').avg
Note: When a future date is used with
age()
, a negative value is returned
Anniversary
The function .anniversary
returns the next anniversary of a date
node.startDate.anniversary
The returned date may be Formatted with use of the .format() function
node.startDate.anniversary.format("dd MMM yyyy")