#GroupBy query based from 'from' and 'to' dates

6 messages · Page 1 of 1 (latest)

stark vortex
#

Is there a way to group by dates even when it's between 'from' and 'to' dates? If I have an entry where its 'from' date is October 10 and 'to' date October 13, it should be grouped into dates October 10, 11, 12, and 13.

unique badge
#

Use whereBetween to get the date range and then group by date

#

Model::whereBetween($from,$to)->groupBy(“date”)->get()

void pumice
void pumice
#

AFAIK there's no easy way to do this with a query. I think you'd have to join a query where you generate the intermediate dates manually. It'd be much easier to in PHP if you have that option.

trim moss
#

What operation you are planning to do with the group by (SUM, AVG?). If you have one row and two dates, and you want to group by days in that period, how do you want to split the target attribute?