AGE

AGE(birthday, date_format)
Returns the age of someone given their birthday.

birthdayThe birthday of the person.
date_formatThe date format "UK" or "US".

REMARKS
* If "birthday" is after todays date, then a negative value is returned.
* If "date_format" is left blank, then "UK" is used.
* If "dtBirthday" is not a valid date , then #VALUE! is returned.
* The formula to return a persons age in years.
* Alternatively you could use the following formula: =INT(YEARFRAC(TODAY(),"01/07/1977",1))

 A
1=JS.AGE("1 Jul 1977")
2=JS.AGE("1/7/1977")
3=JS.AGE("1/7/77")
4=JS.AGE("1/11/1977")
5=JS.AGE("1/11/1977","UK")
6=JS.AGE("1/11/1977","US")
7=JS.AGE("11/1/1977","UK")
8=JS.AGE("11/1/1977","US")
9=JS.AGE("01/02/1920","UK")
10=JS.AGE("15 March 1976","UK")
11=JS.AGE("1 January 2050")
12=JS.AGE(1/7.1977)
13=JS.AGE(126212)

1 - What is the age of someone who has a birthday on "1/11/1977".
2 - What is the age of someone who has a birthday on "11/1/1977".


Public Function AGE( _ 
         ByVal dtBirthday As Date) _
         As Integer

   If Int(dtBirthday) > 0 Then
      Select Case Month(Date())
         Case Is < Month(dtBirthday)
               AGE = Year(Date()) - Year(dtBirthday) - 1
         Case Is = Month(dtBirthday)
            If Day(Date) >= Day(dtBirthday) Then
               AGE = Year(Date()) - Year(dtBirthday)
            Else
               AGE = Year(Date()) - Year(dtBirthday) - 1
            End If
         Case Is > Month(dtBirthday)
            AGE = Year(Date()) - Year(dtBirthday)
      End Select
   Else
      AGE = CVErr(xlErrNA)
   End If
End Function

Function CalcAge(dteBirthdate As Date) As Long 

Dim lngAge As Long

' Make sure passed-in value is a date.
If Not IsDate(dteBirthdate) Then
dteBirthdate = Date
End If

' Make sure birthdate is not in the future.
' If it is, use today's date.
If dteBirthdate > Date Then
dteBirthdate = Date
End If

' Calculate the difference in years between today and birthdate.
lngAge = DateDiff("yyyy", dteBirthdate, Date)
' If birthdate has not occurred this year, subtract 1 from age.
If DateSerial(Year(Date), Month(dteBirthdate), Day(dteBirthdate)) > Date Then
lngAge = lngAge - 1
End If
CalcAge = lngAge
End Function

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext