carrying out to 2 decimals in query

rkrause

Registered User.
Local time
Yesterday, 21:07
Joined
Sep 7, 2007
Messages
343
I have the following statment to determine age of employees, but when i run the query i just get data like 60,50,44, but i want it to be like 66.55,50.59,44.16 depending on how close they are to their birthday.

(datediff(d,emp.brthdate,getdate())/365) as age,
 
You're using an integer not a real number. Just add the .0 to fool it and you're get a more accurate result, then round as necessary

declare @birth date = '1980-10-20'
select datediff(d,@birth,getdate())/365.0 as age
 

Users who are viewing this thread

Back
Top Bottom