1
I have the following code:
HTML:
<input name="dataInicio" type="text" class="form-control datepicker" placeholder="Data" maxlength="10" autocomplete="off" />
<input name="dataFim" type="text" class="form-control datepicker" placeholder="Data" maxlength="10" autocomplete="off" />
Mysql
`date` DATE NOT NULL,
PHP
$dataInicio = (isset($_POST['dataInicio'])) ? '2017-09-25' : date("Y-m-d", strtotime($_POST['dataInicio']));
$dataFim = (isset($_POST['dataFim'])) ? date("Y-m-d") : date("Y-m-d", strtotime($_POST['dataFim']));
And finally the test I’m doing to return the interval of days I need:
PHP
SELECT date,time,resultCode,hostname,user,sites,qt_acessos,bytes
FROM tblResumo
WHERE
date >= '$dataInicio' AND
date <= '$dataFim'
But I have the return of ALL records, regardless of the date informed in my application form! And what I don’t understand is that by checking in the POST, the values reported for the date range are there correctly. I am printing the values as JSON if this information is useful. Where am I wrong? I anticipate my thanks.
Thanks for the tip, man! I’ll switch to
date
. As to thedatepicker
, I already use it! I had a problem using theBETWEEN
in SQL, for being several conditions in myWHERE
, but still I thank you for the tips and attention! Hug.– Jhonatan Junio