DECLARE @age DATETIME
SET @age = (GETDATE() - emp.Birthdate)
SELECT
emp.BusinessEntityID, emp.BirthDate, @age
FROM
HumanResources.Employee AS emp
WHERE
emp.OrganizationLevel > = 3
AND ((GETDATE() - emp.Birthdate) BETWEEN '1930-01-01 00:00:00.000' AND '1940-01-01 00:00:00.000')
As you pros can see, this will not work, I'm hoping to display the ages of the people who are aged 30-40 with their id, bday and age. declaring the @age is my problem. I tried using substring(getdate...), 2, 2)
but it doesn't seem to work. Any ideas? Thanks