In an input and output control system there is a cad_entrada_saida
table where you have two columns in the dEntrada
and dSaida
database, these two columns are as varchar
, and writing the data in the format dd/mm/yyyy H:i
in> defined by the former Developer .
Performing SELECT
on this table using BETWEEN
returns dates outside the defined range.
SELECT * FROM cad_entrada_saida
WHERE dEntrada BETWEEN '01/01/2017 06:00' AND '01/01/2017 23:00'
I've tried using the str_to_date
SELECT * FROM cad_entrada_saida WHERE dEntrada
BETWEEN str_to_date('01/01/2017 06:00', '%d/%m/%Y %H:%i') AND
str_to_date('01/01/2017 23:00', '%d/%m/%Y %H:%i')
Both queries return dates outside of this range.