Skip to content
Advertisement

PHP – Get Average Handling Time (AHT) from mySQLi Database

I followed this to try to get the AHT from my database.

So, the database structure is:

Therefore, I would like to get the average handling time by tecnico_id.

I tried with:

It outputs this:

The 5.791946308724833, -0.37583892617449666 and 5.416107382550336 are not repeated, I just didn’t wanted to format the table.

To convert it to hours, min and secs I use gmdate('H:i:s', '5.791946308724833'), (as an example), however… The results are not accurate as they should be. What I need to do, is getting the difference between those fields, then getting the average, so I can say, as an example:

tecnico_id’s #3 responseTime is 02 hours and 3 minutes, his activity time is 0 hours and 48 minutes and his AHT per ticket is 3 hours and 0 minutes.

How can I achieve this?

Advertisement

Answer

The way to solve this is actually easy. I used this code to make it work.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement