Skip to content

Instantly share code, notes, and snippets.

@trevorgreenleaf
Created July 15, 2017 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorgreenleaf/b9db0338cbdae0b7670ff985f7bc1172 to your computer and use it in GitHub Desktop.
Save trevorgreenleaf/b9db0338cbdae0b7670ff985f7bc1172 to your computer and use it in GitHub Desktop.
Laravel Query Group, Year, Month, Day
$usage = DB::table('styles')
->select(
DB::raw('count(id) as `total_created`'),
DB::raw("DATE_FORMAT(created_at, '%d-%m-%Y') new_date"),
DB::raw('
YEAR(created_at) year,
MONTH(created_at) month,
DAY(created_at) day')
)
->groupby('year','month','day')
->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment