Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

melx's avatar
Level 4

how to find data in previous date range in laravel

hellow I want to get the logic to find the previous data in date range

Example we fetch data from 2020-04-01 to 2020-05-02, so want to get the data from previous this range

anyone can help the logic from here

this query is just return the data of date range, but not previous

                public function stock_by_period(Request $request){
                       $from = date('Y-m-d', strtotime($request->from);
                      $to = date('Y-m-d', strtotime($request->to)

                     $data=Loading::whereBetween('reservation_from', [$from, $to])->get();

                       dd($data);
                 }
0 likes
1 reply

Please or to participate in this conversation.