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

wilch's avatar
Level 1

GroupBy date - same month different year

Hi

I have a timesheet application where I registrate working hours each day. I started using it in June 2015. I have a view on the application where I can choose (from a dropdown) month and display the days and hours I have worked that given month. Now when I want to view my worked hours in June 2016 i am not able to choose this from my dropdown list. The problem is in the groupBy, but I can't seem to find a working solution. I appreciate any help.

This is where I get my selection for the select dropdown.

   /*
         * Delivers the list of months for the dropdown
         */
        $alle = DB::table('timesheet')->selectRaw("DATE_FORMAT(date,'%Y-%m-%d') as date, DATE_FORMAT(date,'%M %Y') as dateshow")
            ->orderBy(DB::raw("YEAR(date)","MONTH(date)"))
            ->groupBy(DB::raw("MONTH(date)"))
            ->simplePaginate(20);
0 likes
0 replies

Please or to participate in this conversation.