0
Why when I run the query below, it returns records:
SELECT COUNT(DISTINCT(dadf332.numped)) AS qtdped,
DATE_FORMAT(dadf331.datlan, '%d/%m/%Y') AS datavenda
FROM dadf331, dadf332
WHERE dadf331.numped = dadf332.numped
AND tipped = 0
AND dadf331.datlan >= '2018-04-01'
AND dadf331.datlan <= '2018-04-03'
qtdped datavenda
------ ------------
24 02/04/2018
It returns record on 02, however if I run the query until 02, it returns nothing?
SELECT COUNT(DISTINCT(dadf332.numped)) AS qtdped,
DATE_FORMAT(dadf331.datlan, '%d/%m/%Y') AS datavenda
FROM dadf331, dadf332
WHERE dadf331.numped = dadf332.numped
AND tipped = 0
AND dadf331.datlan >= '2018-04-01'
AND dadf331.datlan <= '2018-04-02'
qtdped datavenda
------ -----------
0 (NULL)
Probably the field
dadf331.datlan
isdatetime
and has hours on the record. It should work if you do the restriction like this:... AND dadf331.datlan <= '2018-04-02 23:59:59'
– Diego Rafael Souza
@Diegorafaelsouza really it is datetime, had not connected me, and its use DATE_FORMAT(datlan, '%Y/%m/%d') >= DATE_FORMAT('2018-04-02', '%Y/%m/%d')
– wribeiro
That. It should work as well, but it does a little damage to performance, neh?!
– Diego Rafael Souza
@Diegorafaelsouza ah yes it worked, it is because I pass this date as parameter, through 2 inputs, and the input only sends the date
– wribeiro