AGE OF A PERSON in Years; Months & Days format

One of my trainee asked me a user defined function to calculate the age of a person with reference to a date.  This is required for him to ensure the candidates age for selection process.

My suggestion would be to use the below code in Excel VB enviornment.

The following code is named as Myage, to call from Excel.

The 2 input are date of birth of candidates and the standard date used for age validation.

Input : DOB - 04 Oct 1980, 01 Dec 2015

Output: My age is 35 YEARS; 1 MONTHS & 27 DAYS.

Copy the below code and paste in your excel VB environment in Module 1

-------------------------------------------------------------------------------------------------------------------

Function Myage(DOB, asondate)

Td = asondate
X = Year(Td) - Year(DOB)
Y = Month(Td) - Month(DOB)
Z = Day(Td) - Day(DOB)

If Z < 0 Then
Y = Y - 1
Z = Z + 30
End If

If Y < 0 Then
X = X - 1
Y = Y + 12
End If

Myage = "My age is " & X & " YEARS; " & Y & " MONTHS & " & Z & " DAYS."

End Function