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'";