You could GROUP BY date periods. https://www.mysqltutorial.org/mysql-group-by.aspx
Mar 30, 2022
23
Level 5
Break attendance report into pay periods.
I can't seem to figure out the best way to do this. Each employee punches in and out daily. The punch record shows employee_num, date, time in, time out, etc.
Is there an easy way to break the data into pay periods? We start ours the first week of the year and go 14 days.
Currently, I have to get each pay period separately:
$weekOne = $this->getWeekOne($employee, $weekOneStartDate, $weekOneEndDate);
$weekOneTotal = $weekOne->sum('total_time_converted');
$weekOnePto = $weekOne->sum('pto');
$weekOneOt = $weekOne->sum('overtime');
$weekOneHol = $weekOne->sum('holiday');
$weekOneGrandTotal = $weekOneTotal + $weekOnePto + $weekOneOt + $weekOneHol;
$weekTwo = $this->getWeekTwo($employee, $weekTwoStartDate, $weekTwoEndDate);
$weekTwoTotal = $weekTwo->sum('total_time_converted');
$weekTwoPto = $weekTwo->sum('pto');
$weekTwoOt = $weekTwo->sum('overtime');
$weekTwoHol = $weekTwo->sum('holiday');
$weekTwoGrandTotal = $weekTwoTotal + $weekTwoPto + $weekTwoOt + $weekTwoHol;
Please or to participate in this conversation.