Viewing 15 posts - 3,211 through 3,225 (of 3,348 total)
Hi Scott & GSquared,
My common sense was actually not about when a birthdate is (I have at times celebrated by birthday several days before or after the day I was...
March 11, 2008 at 9:51 am
GSquared (3/10/2008)
I took Leap Years into account, and even (to be totally anal retentive about it), the hour, minute, second, and number of milliseconds, on each time.
Maybe I'm...
March 10, 2008 at 4:40 pm
GSquared (3/10/2008)
select datediff(yy, @dateofbirth, getdate()) -
case
when dateadd(year,
datediff(yy, @dateofbirth, getdate()),
@dateofbirth) > getdate() then 1
else 0
end
This takes the datediff, adds it back to the...
March 10, 2008 at 1:13 pm
Lynn Pettis (3/10/2008)
datediff(yy, @dob, @calcDate) - case when (datepart(dy, @calcDate) < datepart(dy, @dob)) then 1...
March 10, 2008 at 12:41 pm
Jamie Longstreet (3/10/2008)
March 10, 2008 at 11:06 am
Rick Harker (3/10/2008)
March 10, 2008 at 10:39 am
Jamie Longstreet (3/10/2008)
Not sure what you mean but I took the date you implied (37 years and 9 months ago) and ran the routine and came up with 37 and...
March 10, 2008 at 10:22 am
Rick Harker (3/10/2008)
I would like to point out that my little proc has not been shown to be wrong... 🙂(I was hoping for some sort of feedback.)
Sorry, Rick - I...
March 10, 2008 at 10:00 am
Jamie Longstreet (3/10/2008)
http://www.sizes.com/time/cal_gregorian.htm
Try changing the Int to Round. Note that the calculation takes into account the factors you mentioned. I just put this one out there...
March 10, 2008 at 9:47 am
Hi Jamie,
Interesting approach - but unfortunately, it shares the problem also exhibited by several other suggestions posted here, that it won't work correctly in non-leap years.
For instance, the calculated difference...
March 10, 2008 at 8:36 am
Mohan Kumar (3/8/2008)
Hence, none can provide correct answer all the time so most close answer is option 2.
If you look back through the 12 pages of discussion, you'll see several...
March 9, 2008 at 1:36 am
Robert Price (3/8/2008)
I'm sure I wasn't the first to notice this...
March 8, 2008 at 3:09 pm
louie.cowen (3/7/2008)
March 7, 2008 at 2:57 pm
mpeverill (3/7/2008)
-- Best way to do itSelect DATEPART( yyyy,Cast((Cast(GetDate() as decimal(9,2)) - Cast(@DateOfBirth as decimal(9,2))) as Datetime))-1900
Nope. This formula says that someone born on March 5 2003 is 1 year...
March 7, 2008 at 9:41 am
Trader Sam (3/7/2008)
Hugo Kornelis (3/7/2008)
(still waiting for a correct answer to be added so that I can finally get back to my track record of 100% of all QotD's attempted)
Hugo...
March 7, 2008 at 8:11 am
Viewing 15 posts - 3,211 through 3,225 (of 3,348 total)