December 7, 2006 at 3:27 am
Indeed it does. Interesting, haven't noticed that before.
Though it appears that if we replace FLOOR/CEILING with ROUND, it will take care of that. It seems to work the same as the CASE variant.
select cast(round(datediff(day, dob, getdate()) / 365.25, 0) as int)
/Kenneth
December 7, 2006 at 8:51 am
Unfortunately ROUND is a lot worse than FLOOR as six month ranges fail to show correctly.
dob DateFrom DateTo RoundAge CaseAge
-------- ------------ --------- -------- -------
19460624 19461224 19470623 1 0
19460624 19471224 19480623 2 1
19460624 19481224 19490623 3 2
etc
December 8, 2006 at 8:54 am
Mmm.. slippery bastards those rounding errors..
It does indeed seem like your case variant is the most straightforward and accurate way.
/Kenneth
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply