0
I need to search the bank records between two dates.
example:
$emprestimos_material_qtd = MultimeiosDetalheEmprestimo::
where('recursoId', 2)
->where('dataDevolucao', null)
->whereDate('dataEmprestimoSaida', '>=', '2019-02-07 16:00:00')
->whereDate('dataEmprestimoDevolucao', '<=', '2019-02-14 15:06:00')
->get();
In the database I have the following records
(7, 12, 2, 'agendado', '2019-02-07 16:00:00', '2019-02-09 13:00:00', NULL, '10.1.2.113', NULL, 182, NULL, 3, NULL, '2019-02-04 19:04:36', '2019-02-04 19:04:36'),
(10, 13, 2, 'agendado', '2019-02-07 16:00:00', '2019-02-09 13:00:00', NULL, '10.1.2.113', NULL, 182, NULL, 3, NULL, '2019-02-04 19:05:37', '2019-02-04 19:05:37'),
-- (13, 15, 2, 'agendado', '2019-02-13 15:06:00', '2019-02-14 15:06:00', NULL, '10.1.2.113', NULL, 182, NULL, 3, NULL, '2019-02-05 17:15:38', '2019-02-05 17:15:38'),
-- (14, 15, 2, 'agendado', '2019-02-13 15:06:00', '2019-02-14 15:06:00', NULL, '10.1.2.113', NULL, 182, NULL, 3, NULL, '2019-02-05 17:15:38', '2019-02-05 17:15:38'),
NOTE: The first date is the date field.
In my opinion he should bring the 4 records, but he brings only 2, the first that has equal values of the field datePress to the query is not returned.
The records on marked is selected , the others not despite meet the rule of equality.
Note: Same case I change the search to $emprestimos_material_qtd = Multimeiosdetailseemprestimo: Where('recursoId', 2) ->Where('dataDevolution', null) ->whereDate('dataEmprestimoSaida', '>=', '2019-02-07 16:00:00') ->get();
Continues to bring only the last two table records
The condition was to see if
dataEmprestimoSaida
is greater than the value and alsodataEmprestimoDevolucao
minor or check a condition or other ?– Bulfaitelo
It is to check the two conditions, that is to search for all the records that are in this interval
– Murilo
but there is no interval, the condition (the query says so) it will return all records that are
'dataEmprestimoSaida', '>=', '2019-02-07 16:00:00'
and who also have'dataEmprestimoDevolucao', '<=', '2019-02-14 15:06:00'
– Bulfaitelo
Ideal and you mount the sql and see if it responds as it should, which and the column
dataEmprestimoSaida
anddataEmprestimoDevolucao
– Bulfaitelo
The first date is the Date Date and the second date is the Date Date. Even if I leave only the first condition that is ->whereDate('dateEmprestimoSaida', '>=', '2019-02-07 16:00:00') it will continue to bring only the last two records, ie the ones that are equal it does not return.
– Murilo
I’ll answer a test I did here see if it will solve your problem.
– Bulfaitelo