Grouping by 15 days( 1 ~ 15 ) / ( 16 ~ end of month ).

Posted 1 month ago by SangminKim

Hi everyone,

I have a query that groups billing information by month. However, I'd like to tweak it so that the query retrieves billing information by 15 days - i.e. ( 1 ~ 15 ) / ( 16 ~ end of month ).

$billings = Billing::select(\DB::raw("YEAR(billing_date) as year,
                                            MONTH(billing_date) as month,
                                            SUM(subtotal + extra_fee) as subtotal,
                                            SUM(gst) as gst, SUM(pst) as pst,
                                            SUM(subtotal) as total"))
                            ->orderBy('year', 'desc')
                            ->orderBy('month', 'desc')

What would be the best way to do it with eloquent?


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.