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
 General SQL Server Forums
 New to SQL Server Programming
 calculating the age

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-09-24 : 13:20:18
what is the syntax of calculating the age of a person using the datediff function and getdate if there is any?

Roger DeFour

X002548
Not Just a Number

15586 Posts

Posted - 2010-09-24 : 13:42:06
[code]

DECLARE @dob datetime; SET @dob = '10/2/1960'
SELECT DATEDIFF(Month,@dob,GetDate())/12.00
[/code]



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx





Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-09-24 : 14:00:25
Computing the age of someone is more difficult than it might seem when you take into account different month lengths, leap year, and other things.

This function returns age in years.
Age Function F_AGE_IN_YEARS:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74462


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -