Reputation: 113
I'm trying to select all records from date 2018-10-01
to date 2018-10-09
.
I would shorten the number of results over time over 06:00:00 and less then 14:00:00.
I did the following:
$radno_vr = ' 14:00:00';
$pocetak_smjene = ' 06:00:00';
$od_datuma_tabl = DateTime::createFromFormat('Y-m-d', $od_datuma)->format('Y-m-d' . $pocetak_smjene);
$do_datuma_tabl = DateTime::createFromFormat('Y-m-d', $do_datuma)->format('Y-m-d' . $radno_vr);
$trazi_podatke = "SELECT * FROM podaci_kotl WHERE sifra_objekta = '$sifra_objekta_trazi' AND datum > '$od_datuma_tabl' AND datum < '$do_datuma_tabl' ... ";
But It works fine, the date over takes all the results longer than 06:00:00 to 14:00:00 but from the last selected date. I'm trying to make a selection from every day but only if there is a record between 06:00:00 and 14:00:00.. Any suggestions?
Upvotes: 0
Views: 61
Reputation: 14618
You need to filter on time.
https://dev.mysql.com/doc/refman/5.7/en/time.html
[...] AND TIME(datum) > TIME('$od_datuma_tabl') AND TIME(datum) < TIME('$do_datuma_tabl')
Upvotes: 2