How to consult from the current system date without having to specify the following
fechaEntrada BETWEEN CONVERT(DATETIME, '2017-11-01 00:00:00',121) and
CONVERT(DATETIME,'2017-11-01 23:59:59',121
The query:
select c.CodeCompany,
CONVERT(char(6), GETDATE(), 112) AS fechaActual,
a.idClave,
c.nombre + ' ' + c.apellidos as Nombre,
d.Descripcion as Depto,
CONVERT (date, GETDATE()) fechaEntrada,
CONVERT (date, GETDATE()) fechaSalida,
DATEDIFF(HOUR, fechaEntrada, fechaSalida) %24 AS horasAlDia
from tblasistencia a JOIN tblpersonal c ON a.idClave=c.idClave
JOIN tblDepto d ON c.fkDepto=d.idDepto
where
fechaEntrada BETWEEN CONVERT (time, SYSDATETIME('00:00:00')) and
CONVERT (time, SYSDATETIME('23:59:59'))
This is incorrect because SYSDATETIME does not receive arguments; however the query must take the records from 00:00:00 until 23:59:59 of the day or the current date