• Calculating Age (Access 2003)

    Author
    Topic
    #430130

    Can you help settle an argument, please?
    We have a DB of club membership and want to be able to calculate age of a member at time of joining. We obviously capture date of birth.
    Now it seems (to me) like calculating age is complicated, with leap years and all, but someone claims that all that needs to be done is :
    Take DOB from Now() which gives number of days – then divide by 365.25 and take integer bit.
    Is it really that simple?

    Viewing 2 reply threads
    Author
    Replies
    • #1003527

      I believe it can fail in certain very specific (and rare) circumstances. That is, it can sometimes be off by like 1 day, which isn’t a problem except if person’s birthday happens to be today. For example, do the math on birthdate of 3/1/01 and a “today’s” date of 3/1/06.

    • #1003528

      Yes, it can be wrong by a day occasionally. Remember that a calendar year is NOT 365.25 days; it is 365 days 3 out of 4 years and 366 days 1 out of 4 years (I’m ignoring the “century rule”). The Access help provides an accurate age calculation –
      =DateDiff(“yyyy”, [Birthdate], Now())+ Int( Format(now(), “mmdd”) < Format( [Birthdate], "mmdd") )

    • #1003532

      Another custom age function (this one from the Access 97 code samples database) is

      Function Age(Bdate, DateToday) As Integer
      ‘ Returns the Age in years between 2 dates
      ‘ Doesn’t handle negative date ranges i.e. Bdate > DateToday
      Age = Year(DateToday) – Year(Bdate)
      If Month(DateToday) < Month(Bdate) Or (Month(DateToday) = Month(Bdate) And Day(DateToday) < Day(Bdate)) Then
      Age = Age – 1
      End If
      End Function

      • #1004192

        Thank you Mark, Douglas and Hans
        I knew it wasn’t that simple!
        Sorry for the delay in replying
        Silverback

    Viewing 2 reply threads
    Reply To: Calculating Age (Access 2003)

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

    Your information: