Subject | Re: [firebird-support] Re: Age Calculation |
---|---|
Author | Helen Borrie |
Post date | 2008-11-29T06:01:36Z |
At 04:32 PM 29/11/2008, you wrote:
So, in short, you'll need to take "the long route" using successive EXTRACTs if you're writing software for an astrologer or figuring out what airfare to charge my grandchildren. ;-)
./heLen
>--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...>Indeed, when you have MONTH as your level of granularity, that's as good as you can do, even if you fail to allow for integer division (as your example does). If you take the granularity to DAY and divide the result by 365.25, you do get enough granularity but not absolute accuracy, if the person's life has jumped over a century boundary (as is the case for most adults alive today).
>wrote:
>>
>> At 11:35 PM 28/11/2008, you wrote:
>> >I need to add a computed column to a table to evaluate a person's
>age.
>> >What is the best way to calculate age? DateDiff(Year, BirthDate,
>> >CURRENT_DATE) seems only to take account of the year portion of the
>> >dates and not the month and day parts.
>> >Regards
>> >Peter Gore
>> >Using FB2.1
>>
>> (DateDiff(Month, BirthDate, CURRENT_DATE)) /12.00
>>
>> ./heLen
>>
>Unfortunately this approach makes the following evaluation 21 whereas
>it should not be 21 until 25-nov-2021
>select (DateDiff(Month, CAST('25-nov-2000' as Date), CAST('1-nov-
>2021' as Date))/12) from rdb$database
So, in short, you'll need to take "the long route" using successive EXTRACTs if you're writing software for an astrologer or figuring out what airfare to charge my grandchildren. ;-)
./heLen