KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Adding up HH:SS times #1257

Open Andrew Guattery opened this topic on on Jan 13, 2020 - 1 comments

Andrew Guattery commented on Jan 13, 2020

Ok KoolReport Gurus, I am creating a payroll report and need to add up the total time worked per employee. Data is in MSSQL time format. I know in MSSQL I can do something like this:

select cast(dateadd(millisecond,sum(datediff(millisecond,0,cast(<time column> as datetime))),0) as time) FROM table>

but how to do it in a KoolReport function? So in the user group I already have some other aggregate functions such as:

"{countAvailable}"=>function($store){
                    return $store->filter("<column to count>",">",0)->count();
                }

But times have got me stumped.

KoolReport commented on Jan 14, 2020

PHP has number of function to deal with datetime for example the diff() function here.

You can consider $store as an 2-dimension array so you can loop through each item of $store like row of table, get the column to count, convert it to the datetime and use the method lile diff() to calculate before return your own count.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None