I have something like this:
$from = min($start_date, $end_date);
$till = max($start_date, $end_date);
DB::table('booked')
->where('start', '<=', $from)
->where('end', '>=', $till)
->get();
This is a nice solution form stackoverflow.
It seems works, but I need the opposite.
In my DB I have this data: start: 2020-09-27 10:00:00 end: 2020-09-27 12:00:00 I have to query that rows where for example:
$start_date(2020-09-27 9:00:00) and $end_date(2020-09-27 11:00:00) where both not in start: and end: Hopefully my question is clear enough.
2020-09-27 11:00:00is between the given range and your telling in opposite waystart - 10, end = 12and now if input range isstart = 8, end = 9=> yes,start = 9, end = 11=> no,start = 11, end = 11:30=> no,start = 11, end = 13=> no,start = 13, end = 14= yes. If that so, will give you a query