PHP To Calculate Total Hours Within Applied Filters


I have a page located at /total-hours on my site that uses an SQL calculation to display data to the screen using a plugin called wpDataTables. The table ID is 50 so I use the shortcode [wpdatatable id=50]

One of the columns is total hours and it display a string value of the HH:MM which is calculated as the difference between the time entered into Start Time and the Value entered into End Time.

The wpDataTable plugin allows filters to be applied to the columns and the results displayed are filtered based on these inputs.

What I would like to achieve here is a php query or something that will calculate the total hours from that column in the format HH:MM that updates as the filters are applied. Pagination is built into the results so I am happy to ignore the pagination in terms of the calculated total, it should be the total filtered results which might be 50 results over 5 pages of 10 per page. The total should be all 50 records not just the 10 displayed.

Can anyone work this out for me?

I have support access granted and you can visit the page logged in as my account to see what I mean. I have put a total hours field at the bottom which currently calculates the total using a separate SQL query but it does not give me the hours filtered as per the inputs to the wpDataTable.