View Full Version : carrying out to 2 decimals in query


rkrause
05-13-2011, 06:15 AM
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,

pilsdumps
06-01-2011, 05:37 AM
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