YearsBetween – XpressDox

The YearsBetween function returns the approximate number of years between the two dates.

 

The reason that it is approximate is that it is calculated as the number of days between the two dates divided by 365.25. Thus for a long time period, the result will be more accurate than for a short time period. Using the floor (round down) or ceiling (round up) functions can help.

 

Calculate decedent’s age at death:

Date of birth: «FormatDate(Birth,’d mmmm yyyy’)»
Date of death: «FormatDate(Death,’d mmmm yyyy’)»
«AgeAtDeath»

«Comment(Show the age at death in the interview)»
«OnExitSet(Death,AgeAtDeath,Value,(),Floor(YearsBetween(Death,Birth)),,EvenWhenNotEmpty)»

«Comment(This is for the document)»
Age at death: «Floor(YearsBetween(Death,Birth))»

 

 

Calculate a person’s current age:

I was born on «FormatDate(DateOfBirth,‘d MMMM yyyy’)» which means I am «floor(YearsBetween(Today(),DateOfBirth))» years old.

 

 

Calculate age at next birthday i.e. round up:

The insurance industry sometimes likes to use “age next birthday” which would be calculated as:

I was born on «FormatDate(DateOfBirth,‘d MMMM yyyy’)» which means that my age at next birthday will be «ceiling(YearsBetween(Today(),DateOfBirth))» years.

See also The DaysBetween Function to see how to get the number of days between two dates.