devxlogo

Calculate Age Using DateDiff

Calculate Age Using DateDiff

Use the function DateDiff to calculate an individual’s exact age based on birth date. DateDiff first calculates the total number of days an individual has been alive and then divides by 365.25 to account for leap years. The Int function truncates the division results by removing the decimal and not rounding:

 Function CalcAge(datEmpDateOfBirth as Variant) as Integer	CalcAge = Int(DateDiff("y",datEmpDateOfBirth,Date())_		/365.25)End Function

devx-admin

Share the Post: