Using BETWEEN with DATETIME database fields it does not return any records with date equal to datei and dataf.
Using DATE_FORMAT to search by date by ignoring TIME Considering the search $ dtai = '01 / 06/2016 'and $ dtaf = '06 / 05/2016', returns results only between 02/06/2016 and 05/05/2016, no data returned for the period searched, in the database there is data for the period searched.
SELECT u.Nome, u.Email, DATE_FORMAT(cp.DataSolicitacao,'%d/%m/%Y') as DataSolicitacao, cp.CodigoPromo, cp.IdTransacao
FROM cartao_pedidos AS cp
INNER JOIN usuarios AS u ON u.Id = cp.IdUsuario
INNER JOIN codigospromo AS cpp ON cpp.Numero = cp.CodigoPromo
WHERE cpp.IdColaborador = :idc AND cp.DataSolicitacao BETWEEN DATE_FORMAT($dtai,'%Y-%m-%d') AND DATE_FORMAT($dtaf,'%Y-%m-%d')
DataTest field is type DATATIME, and records in the database are recorded with TIME, eg. 2016-05-06 15:51:35. I'm using PDO. How do I return the records to the search dates?