Query error by date

1

In my application I have a query by date, below is a snippet of the script

tblacesso.HorarioSaida BETWEEN '2017-06-17 00:00:00' AND '2017-06-17 23:59:59'

But he is not selecting the data of the day in question, below is an image in the data in the bank.

IfIchangeto:tblacesso.HorarioSaidaBETWEEN'2017-06-1600:00:00'AND'2017-06-1623:59:59'somedataappears,butitappearsuntilthe17thaswell.

Theentirequeryis:

$sql="SELECT tblacesso.Codigo, tblfrota.Codigo AS CodigoFrota, tblpessoa.NomeCompleto, tbldestino.Descricao, tblacesso.KMSaida, tblacesso.KMEntrada, "
        . "DATE_FORMAT(HorarioSaida, '%d/%m/%Y %H:%i:%s') AS 'DataSaida', "
        . "DATE_FORMAT(HorarioEntrada, '%d/%m/%Y %H:%i:%s') AS 'DataEntrada' "
        . "FROM tblacesso "
        . "INNER JOIN tblfrota ON(tblacesso.FrotaID = tblfrota.Codigo) "
        . "INNER JOIN tblpessoa ON(tblacesso.MotoristaID = tblpessoa.Codigo) "
        . "INNER JOIN tbldestino ON(tblacesso.DestinoID = tbldestino.Codigo)"
        . "WHERE tblacesso.Status = false AND DATE(tblacesso.HorarioSaida) BETWEEN '".$data. " 00:00:00' AND '" .$data." 23:59:59'";
    
asked by anonymous 19.06.2017 / 14:55

3 answers

2
tblacesso WHERE HorarioSaida >= '2017-06-16 00:00:00' AND HorarioSaida <= '2017-06-16 23:59:59'

    
19.06.2017 / 16:13
0

Try to do this:

DATE(tblacesso.HorarioSaida) = '2017-06-17'
    
19.06.2017 / 15:33
0

Try this:

tblacesso.HorarioSaida >= '2017-06-17 00:00:00' AND tblacesso.HorarioSaida <= '2017-06-17 23:59:59'
    
19.06.2017 / 16:59