Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calculating Age (Access 2003)

    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?
    Silverback

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Calculating Age (Access 2003)

    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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calculating Age (Access 2003)

    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") )

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Calculating Age (Access 2003)

    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

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calculating Age (Access 2003)

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •