• Age calculation

    Author
    Topic
    #352240

    I am using the following function to work out the age of someone.

    DateDiff(“yyyy”, DOB, Date)

    The DateDiff calculation does not look at partial months, ie dob 12/05/90 will produce an age of 11 even though they are only 10. Can anyone help??

    Viewing 0 reply threads
    Author
    Replies
    • #511692

      Try this function

      Function Age(Bdate, DateToday) As Integer
      ‘ Returns the Age in years between 2 dates
      ‘ Doesn’t handle negative date ranges i.e. Bdate > DateToday

      If Month(DateToday) < Month(Bdate) Or (Month(DateToday) = _
      Month(Bdate) And Day(DateToday) < Day(Bdate)) Then
      Age = Year(DateToday) – Year(Bdate) – 1
      Else
      Age = Year(DateToday) – Year(Bdate)
      End If
      End Function

      Good luck

      Richard Aheron
      raheron@hotmail.com

      • #511699

        i put this code in the oncurrent event
        yourTextbox = DateDiff(“yyyy”, [BirthDate], Now()) + Int(Format(Now(), “mmdd”) < Format([BirthDate], "mmdd"))
        hope it helps
        JerryC

    Viewing 0 reply threads
    Reply To: Age calculation

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: