Age calculation with SQL Server

There seem to be many different methods being suggested to calculate an age in SQLServer.  Some are quite complex but most are simply wrong.  This is by far the simplest and accurate method that I know.

Declare @Date1 datetime
Declare @Date2 datetime

Select @Date1 = '15Feb1971'Select @Date2 = '08Dec2009'select CASE
WHEN dateadd(year, datediff (year, @Date1, @Date2), @Date1) > @Date2
THEN datediff (year, @Date1, @Date2) - 1
ELSE datediff (year, @Date1, @Date2)END as Age

happy coding

About Asif
Hello Friends… I have done my Bachelor of Engineering in Information Technology from Gujarat University. I have 1.7 years experience of web and windows based application development.. My basic idea to start a blog is to store all important link which help me in my application and access to every where. Also this information is help others who want to makes their application powerful. I am interested in .net framework (1.0,2.0,3.0,3.5 and more). This blog contain also many information related to SQL, Custom Controls in Please share your ideas and any query if you have...

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: