Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Finding Birthdate from age

Author  Topic 

CSK
Constraint Violating Yak Guru

489 Posts

Posted - 2007-11-30 : 10:26:17
All,

I am trying to find out the birthdate from Age,
I have tried the below query, I am not geting the exact output.
can any one help to find out what is wron in my query..?

DECLARE @Age NUMERIC(10,4),
@todaydt DATETIME
SET @todaydt = GETDATE()
SELECT @Age = FLOOR(DATEDIFF(dy, '11/07/1978'/*Format:DD/MM/YYYY*/, @TodayDt)/365.25)

SELECT DATEADD(DAY, -1,(DATEADD(YEAR, (-1 * @Age) - 1, @TodayDt)))


Thanks
krishna

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2007-11-30 : 10:43:52
Check this out
http://www.umachandar.com/technical/SQL6x70Scripts/Main13.htm


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-01 : 14:57:32
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74462



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -