I want to get records that are joined between this date period (2022-02-15, 2022-08-20)
$users = User::whereDate('start_at', '>=', $startDate)
->whereDate('end_at', '<=', $endDate)
->get();
I want to get records that are joined between this date period (2022-02-15, 2022-08-20)
$users = User::whereDate('start_at', '>=', $startDate)
->whereDate('end_at', '<=', $endDate)
->get();
4
Answers
You can use the whereBetween Laravel function:
Note $startDate and $endDate must be instance of Carbon.
Update
This would be one method to get data from two seperated columns. Example is not tested.
try above code this will also return between dates of start_date and end _date e.g below
and also works with below dates e.g
codes look like this in ide
Depends on what you need exactly
or
I think you want to get the records that at least one day from
start_date
toend_date
that exists between 2022-02-15 and 2022-08-20: