User:Help4u123/sandbox

find age in year from date of birth from current date using sql query in sql server2005

DECLARE @birthdate SMALLDATETIME, @endDate SMALLDATETIME SET @birthdate = '19791204' SET @endDate = GETDATE

SELECT DATEDIFF (    YEAR,     @birthdate,     @endDate ) - CASE WHEN 100 * MONTH(@endDate) + DAY(@endDate) < 100 * MONTH(@birthdate) + DAY(@birthdate) THEN 1 ELSE 0 END