Leading the way in Microsoft Office Development
 Home|Excel|Word|PowerPoint|Consultancy|Feedback|Contact 
 Microsoft Excel > Functions User Defined > AGE< Previous | Next > 

 

AGE(dtBirthday)

 
 

Returns the age of a person given a birthday.

 

 
dtBirthdayThe date of the birthday.
 

 

REMARKS

 
 
  • If "dtBirthday" is not a valid date , then #VALUE! is returned.

     

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    Option Explicit

    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
       

     

    Example

     
       

     Copyright © 2004-2007 Better Solutions Limited. All Rights Reserved.< Previous | Top | Next >