SQL Query to Find Employees Who Have Been with the Company for More Than 5 Years

Given a table of employee data, this SQL query will find all employees who have been with the company for more than 5 years.

Problem

Given a table of employee data, write a SQL query to find all employees who have been with the company for more than 5 years.
Example input:
| EmployeeID | Name       | StartDate       |
|------------|------------|-----------------|
| 1          | John Doe   | 01/01/2010      |
| 2          | Jane Smith | 03/04/2015      |
| 3          | Joe Brown  | 05/12/2012      |
Example output:
| EmployeeID | Name       | StartDate       |
|------------|------------|-----------------|
| 1          | John Doe   | 01/01/2010      |
| 3          | Joe Brown  | 05/12/2012      |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT EmployeeID, Name, StartDate
FROM Employee
WHERE StartDate < DATEADD(year, -5, GETDATE())

A.I. Evaluation of the Solution

This solution is complete and solves the problem. The approach is straightforward and easy to follow.

Evaluated at: 2022-11-24 00:15:55