Filter query for mysql dates

Asked

Viewed 31 times

0

have this mysql table: inserir a descrição da imagem aqui

And I have the following appointment:

SELECT *
FROM tabela
WHERE 1 = 1
AND data_prova >= '2020-03-01'
AND data_prova <= '2020-03-26'

Well, with this select use for a filter and was to return me the last three lines, but it only returns me the day 02-03 and 24-06, the day 26-03 does not return, which error?

The field data_prova is the type datetime, and the date I’m putting as string.

1 answer

1


You did not enter the time together with the time date. With this it assumes the standard "00:00:00.000" for the time.

Try:

SELECT *
FROM tabela
WHERE
 data_prova >= '2020-03-01 00:00:00.000'
AND data_prova <= '2020-03-26 23:59:59.999'
  • Vlw, you did. But on account of not using the minutes I just put the date before the fields like this: date(hp.data_proof) for him to understand that I only want the date. Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.