You could adapt this query
Share your code if any difficulty
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have a lot of data in one month during this one year, i am confused how can i retrieve data on the last date of every month for one year in laravel.?
tried to use this code but it's not what I want
$dateS = Carbon::now()->startOfMonth()->subMonth(12);
$dateE = Carbon::now()->startOfMonth();
$q = DB::table('rep_daily')
->select('rdn_val','created_at','eks_id')
->whereBetween('created_at',[$dateS,$dateE])
->get();
If you want to group by month, your inner sql should be
SELECT month(created_at) AS month,max(created_at) AS created_at FROM trade_daily GROU BY month(created_at);
Please or to participate in this conversation.