1
My code is not working which may be wrong?
In the database the date is with Date/Time as datetime
, follows the code:
<?php
$query = $mysql->query("SELECT * FROM c_clientes WHERE cliente_data_cadastro
BETWEEN '2018-04-07 12:53:14' AND '2018-05-07 12:53:14'");
echo "<center>". mysqli_num_rows($query). " Registros</center>";
while($row = $query->fetch_array())
{
echo $row['cliente_data_cadastro']." - "
.$row['cliente_nome']." "
.$row['cliente_sobrenome']."<br>";
}
?>
But what is not working? And what is the purpose of the code?
– Wictor Chaves
Filter entries within 1 month! Load nothing
– João Pedro Morais
My question is obvious, but have you checked if there are actually existing records within this date range?
– Rogério Dec
Yes I have about 300 records per day! Plus I did tests with DB only with test dates!
– João Pedro Morais
Try
SELECT * FROM c_clientes WHERE ( cliente_data_cadastro 
 BETWEEN '2018-04-07 12:53:14' AND '2018-05-07 12:53:14')
– lazyFox
If the column type is DATETIME, which stores date and time values in the format YYYY-MM-DD hh:mm:ss, why did the hours working? I ran your code through a table in my bank and ran right. The real solution does not seem to me to go through the withdrawal of hours! Some misconception on your part in the database regarding the date column. See this https://i.stack.Imgur.com/zTUfU.png result
– user60252