MS-Access / VBA

H

Halvo

I need to calculate an individual's age but all the formulas that I have seen
or try seem to calculate years only. I need to calculate a result of years
and months to compare ages at the month level. Does anyone know of a formula
or a function that will accurately calculate a person's age and return the
result in years and months?
 
S

Sergey Poberezovskiy

You can get the number of months:

months = DateDiff("m", DateOfBirth, Date)

and then extract the number of years

years = months \ 12

finally you get the result:

Debug.Print "Years: " & years, "Months: " & months -
years*12

HTH
 
Top