LaravelでのDATEDIFF関数を使用した時間差のクエリビルダー
単純なDATEDIFFの使用例:$startDate = '2024-02-01 10:00:00'; $endDate = '2024-02-02 12:00:00'; $diffInHours = DB::table('table_name') ->select(DB::raw('DATEDIFF(hour, ? , ?) as diff_in_hours')) ->setBindings([$startDate, $endDate]) ->value('diff_in_hours'); echo $diffInHours;>>More