Possible Duplicate:
How to calculate age in T-SQL with years, months, and days
calculating age from sysdate and birthdate using SQL Server
In the process of some age calculations. I'm a bit of a novice when it comes to SQL but I've been tasked with singling out persons who will turn 65yrs
old as of 31 March 2013
. So far I'm able to calculate age based on given DOB
, however I'm having issues singling out these persons. I'm thinking this is a simple issue but I'm stumped, see sql statement. Can someone please point me in the right direction.
SELECT ip_master.ssn, ip_master.firstname, ip_master.surname, ip_master.status,
CASE WHEN DATEADD(YEAR, DATEDIFF (YEAR, dob, '2013/03/31'), dob) > '2013/03/31'
THEN DATEDIFF(YEAR, dob, '2013/03/31') - 1
ELSE DATEDIFF(YEAR, dob, '2013/03/31')
END AS 'Age'
FROM test_db.dbo.ip_master ip_master