Sunday, February 6, 2011

Calculate Age in SQL Server

Here is a script to calculate an age of a person using TSQL using Convert().
1:  SELECT FirstName, LastName   
2:    ,CONVERT(Int, DATEDIFF(day, BirthDate,   
3:    GETDATE())/365.25) As Age   
4:  FROM EmployeesDTR  

Source: TSQL Reference

0 comments:

Post a Comment