Re: Calculating and displaying "Age"
From: Steve Z (szlamany_at_antarescomputing.com)
Date: 03/08/04
- Next message: Kevin: "Re: Find differences in Two tables"
- Previous message: Jasper Smith: "Re: Changing Start-up and Agent Accounts"
- In reply to: Gert-Jan Strik: "Re: Calculating and displaying "Age""
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 11:21:11 -0800
Thank you very much - we hate little bugs like that...
I think I'll change the Cast(... as datetime) to a nice CONVERT(CHAR(10),@date,112) to make it a character YYYYMMDD comparison - on both sides of the ">"
----- Gert-Jan Strik wrote: -----
This query will throw an error if the date of birth is on 29th of
February, and SomeDate is not a leap year...
Gert-Jan
Steve Z wrote:
>> We always use:
>> Set @Age=datediff(YYYY,@DOB,@SOMEDATE)
> -CASE WHEN
> CAST(CONVERT(CHAR(6),@DOB,101)+CAST(DATEPART(YYYY,@SOMEDATE) AS VARCHAR(4)) AS DATETIME)
>>@SOMEDATE THEN 1 ELSE 0 END
--
(Please reply only to the newsgroup)
- Next message: Kevin: "Re: Find differences in Two tables"
- Previous message: Jasper Smith: "Re: Changing Start-up and Agent Accounts"
- In reply to: Gert-Jan Strik: "Re: Calculating and displaying "Age""
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|