I have following task:
Show the list of first, last names and ages of the employees whose age is greater than 55. The result should be sorted by last name.
This is my code:
SELECT
LastName, FirstName,
(CASE
WHEN (CONVERT(INT, GETDATE()) - CONVERT(INT, BirthDate)) > 55
THEN CONVERT(INT, GETDATE()) - CONVERT(INT, BirthDate)
END) as Age
FROM
Employees
ORDER BY
LastName
This is what I get:
This is the BirthDate
table (datetime):
Why does the age go so crazy? What's wrong?