CREATE TABLE #TEMP(ID INT, DOB DATETIME)
INSERT INTO #TEMP VALUES(1 , '01/01/1980')
INSERT INTO #TEMP VALUES(2 , '01/02/1980')
INSERT INTO #TEMP VALUES(3 , '01/03/1979')
INSERT INTO #TEMP VALUES(4 , '01/04/1978')
INSERT INTO #TEMP VALUES(5 , '01/05/1955')
INSERT INTO #TEMP VALUES(6 , '01/06/1982')
INSERT INTO #TEMP VALUES(7 , '01/02/1983')
INSERT INTO #TEMP VALUES(8 , '01/07/1984')
INSERT INTO #TEMP VALUES(9 , '01/08/1965')
INSERT INTO #TEMP VALUES(10 , '01/09/1975')
INSERT INTO #TEMP VALUES(11 , '01/10/1947')
SELECT YEAR(GETDATE()) - YEAR(DOB) AS AGE FROM #TEMP
No comments :
Post a Comment