Hello friends, I have problems to extract the year from a date, grouped by date and sort by date using Eloquent
The sql statement I use is:
notifications = DB::select("SELECT EXTRACT(YEAR FROM created_at) AS a,*
FROM notifications
WHERE volcano_id =".$id."
group by created_at,id
ORDER BY created_at");
Hi @omontes, the EXTRACT keyword is very MySQL specific and should not be used directly. You should always try to use some kind of abstracted way to query your data so you can switch your database at anytime. Moreover why don't you extract that value later on directly in your application ?