Why BETWEEN '2020-02-22 00:00:00' AND '2020-02-22 23:59:59'
is working (getting Data)?
AND why BETWEEN '2020-02-22' AND '2020-02-22'
is not working (Not getting Data)?
Edited: Got it. I forgot to add date(created_at)
instead of created_at
Advertisement
Answer
You may use the whereBetween
method
It verifies that a column’s value is between two values.
Expl
$from = date('2018-01-01'); $to = date('2018-05-02'); Model::whereBetween('dateColumn', [$from, $to])->get();
Or
Model::where('dateColumn', '>=', $from)->where('dateColumn', '<=', $to)->get();