KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Calculating an Age in Years
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: November 17, 2000
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

One quick and dirty way to determine a persons approximate age in years given their date of birth (DOB) is:



However, the older a person is the less accurate this technique will be due to leap years. If their birthday happens to be near to the current date the result could be wrong! Here is an accurate method of calculating an age in years:

` calculate a persons age based on their Date Of Birth
Age:=Year of(Current date)-Year of(DOB) ` nominal age
$tempDate:=Add to date(DOB;Age;0;0) ` find their birthday this year
If ($tempDate>Current date) ` has it passed yet?
Age:=Age-1 ` no birthday this year yet - very happy unbirthday
End if