0

In my my laravel 5.7.3 application , I need to get grouped date like

$voteItemUsersResults = VoteItemUsersResult::orderBy('created_at', 'desc')
             ->groupBy('created_at')
             ->having('created_at', '>', '2018-09-01')
             ->get();

but I need to get only day part of created_at, without time.

Which is the valid way to make it ?

1
  • For example, output ?
    – Mohammad
    Sep 22, 2018 at 7:49

1 Answer 1

1

Grouped by Only Day of Datetime .

$voteItemUsersResults = VoteItemUsersResult::orderBy('created_at', 'desc')
             ->groupBy(DB::raw('DATE_FORMAT(created_at, "%d")'))
             ->having('created_at', '>', '2018-09-01')
             ->get();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.