The human resources department needs a report that shows the surname and date of hiring of all employees hired in 1995 or 2005.
How do I do that if the data of the date is a datetime type and the range it asks for is only the year?
The human resources department needs a report that shows the surname and date of hiring of all employees hired in 1995 or 2005.
How do I do that if the data of the date is a datetime type and the range it asks for is only the year?
SELECT APELLIDO, FECHA_CONTRATO
FROM EMPLEADOS
WHERE DATEPART(YEAR,COLUMNA) IN (Año1,Año2)
Something like that can help you. !
I have used this a few times and it has always worked well for me:
"SELECT * FROM $dbTable WHERE date(fecha) BETWEEN 'fecha1' AND 'fecha2' ORDER BY fecha DESC"