The following query is supposed to select the EmployeeID and Hiredate along with number of years hired, year(now)-year(hiredate) as Years where the hire date is exactly 6 months ago or the current month. (The second part of the where clause appears to work. It simply says that years hired should be greater than 10)
Six months ago would be November. The current month of course is May.
However, this query identifies dates that appear on 12/1 which is an error.
I'm assuming this is precision error. But I don't know.
SELECT EmployeeID, HireDate, year(now)-year(hiredate) as Years
WHERE (Month(Now-HireDate)=6 Or Month(Now)=Month(HireDate)) And (year(now)-year(hiredate)>10);
EmployeeID HireDate Years
1 11/9/1994 12
10 11/20/1991 15
21 11/16/1989 17
88 5/16/1989 17
124 12/1/1994 12
133 5/16/1991 15