sql query with double rank using between

0

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?

    
asked by Samuel Ignacio Susana Confesor 12.06.2017 в 21:16
source

2 answers

1
SELECT APELLIDO, FECHA_CONTRATO
FROM EMPLEADOS
WHERE DATEPART(YEAR,COLUMNA) IN (Año1,Año2) 

Something like that can help you. !

    
answered by 12.06.2017 в 21:36
0

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"
    
answered by 12.06.2017 в 21:48