0
I have a table that contains the following fields type name (nvarchar)
, Date of type (Date)
and time like (Time)
.
I need to do the comparison by period example: 08-02-2019 e 18:30:10 até 30-05-2019 e 07:45:11
How do I do this in sql server query
I was trying that way but I know it doesn’t work:
SELECT pessoa.nome, acesso.data, acesso.hora
FROM acesso
INNER JOIN pessoa ON acesso.id_pessoa = pessoa.id
WHERE (acesso.data >= @data1) AND (acesso.data <= @data2) and (acesso.hora >= @horaInicio and acesso.hora <= @horafim)
Combine your date and time fields in a datetime field and make a single check if you are in range.
– anonimo
I cannot change the structure of the bank, because it is third party and there are already several data.
– mba
I did not speak of changing the bank structure but rather combining the fields in your select to make the comparison. I use neither Microsoft SQL Server nor Sqlite to illustrate how to do it.
– anonimo