• rmattaway (3/13/2009)


    One method used by my employer is what we call the window of time. It was decided that everyone in our databases could not be older than 120 years. As such an Age Table was created with the number of days, weeks, months, years, etc. This assures that no matter what you can compute the days between using datediff then look up the age you want to use. This method assures that apples are truly compared with apples because someone that is 3652 days old is the same age as someone else 3652 days old.

    Most of the day-based solutions suffer from a fatal flaw:

    My birthdays are never 365.25 (or .242199, or .2425) days apart.

    They are either 365 or 366 days apart, with the number of days depending on:

    1. Leap Years (this year or last year)

    2. When I was born in the year: Before Feb 29th, on Feb 29th or after Feb 29th

    3. The rules for Leapling birthdays in non-Leap Years

    And for most real-world applications, being exact is important.

    I want to be able to drink, drive, receive benefits, and get paid more on my birthday.

    Approximations just aren't good enough 🙂