lundi 23 novembre 2015

How to order by date in laravel 5 SQL Query?

I want to select the date value and count the number of it's appearance order by the date. this is my SQL Query code:

$b = DB::table('entry')
                        ->select(DB::raw("DATE_FORMAT(created_at,'%d-%m-%Y') as tanggal"))
                        ->groupBy(DB::raw("DATE_FORMAT(created_at,'%d-%m-%Y')"))
                        ->orderBy(DB::raw("CONVERT(DateTime, DATE_FORMAT(created_at,'%d-%m-%Y'), 101)"))
                        ->get();

What's wrong with that query?, help me guys, thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire