Given a DateTime representing a person\'s birthday, how do I calculate their age in years?
DateTime
SQL version:
declare @dd smalldatetime = '1980-04-01' declare @age int = YEAR(GETDATE())-YEAR(@dd) if (@dd> DATEADD(YYYY, -@age, GETDATE())) set @age = @age -1 print @age