Hi @bhhussain,
Something like this?
->groupBy(DB::raw("DATE_FORMAT(job_invoice_date, '%Y-%m-%d')")
?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I am trying to sum the invoice total by grouping the invoice date but it is showing based on date with time
public function index()
{
$arr['jobcard'] = Jobcard::where('job_comp_code', auth()->user()->company)
->where('job_status_name', 'Invoiced')
->selectRaw('job_invoice_date,sum(job_invoice_amount) as total')
->groupBy('job_invoice_date')
->get();
return view('job.jobinvtotal.index')->with($arr);
}
Can anyone please help me to fix it. I already tried in google and spend some time, a different approach is giving different output but I did not get the one I want.
Thank you
It is giving the output like this but it should group the only date
@bhhussain When you use this
public function index()
{
$jobcard = Jobcard::selectRaw('date(job_invoice_date) as date, sum(job_invoice_amount) as total')
->where('job_comp_code', auth()->user()->company)
->where('job_status_name', 'Invoiced')
->groupBy('date')
->get();
return view('job.jobinvtotal.index', compact('jobcard'));
}
In the view you have to use date instead of job_invoice_date
<td>{{ $c->date }}</td>
<td>{{ number_format($c->total, 3) }}</td>
Please or to participate in this conversation.