How to calculate Age using SQL Query
DateDiff function can be used to get the Age from the birth date
Select BirthDate, DateDiff(year, BirthDate, getdate()) as Age from HumanResources.Employee
Monday, April 16, 2007
Subscribe to:
Post Comments (Atom)
4 comments:
That only works for users that have had their birthday already this year. If the users birthday is after the current date, the age is off by 1 year.
Datediff function worked perfectly for me.
Does not work.......
it will work...it will show in negative valueas a age in months...
Select BirthDate, DateDiff(month, BirthDate, getdate()) as Ageinmonths from HumanResources.Employee
http://www.w3schools.com/sql/func_datediff.asp
Post a Comment