1
How do I calculate the time spent on calls answered by an employee? However always within valid working hours, and knowing that the working hours of an employee is between 08hs and 18hs.
For example: table called.
___________________________________________________________
|cod_log|cod_chamado|inicio_log |fim_log | status_log |
| 001 | 100 |25/07 16:00|25/07 17:00| Atendimento |
| 002 | 100 |25/07 17:00|26/07 08:30| Pausado |
| 003 | 100 |26/07 08:30| | Atendimento |
|_______|___________|___________|___________|_____________|
As they can answer multiple calls a day, they have the possibility to leave the calls in pause until the best time to serve it, including leaving for another day.
The calculation of the time spent on answering the call I can recover, but I’m not seeing the best way to leave the calculation of breaks within working hours. In this example above cited the calculated pause of this call should be 1:30 min, that is to say it would only count until the end of your working hours, and from your work start time.
My query is like this:
SET @HoraEntrada = '08:00:00';
SET @HoraSaida = '20:00:00';
SELECT SEC_TO_TIME(TIMESTAMPDIFF(SECOND, q.isl_data_ini, q.isl_data_fim))
as `difference`
FROM insuporte_status_log q
WHERE hour(q.isl_data_ini) >= @HoraEntrada and hour(q.isl_data_fim) <= @HoraSaida
and q.isl_sch_codigo = '100405-573'
and (q.isl_status = 'Pausado')
And yet you keep counting the time that theoretically should be out of range.
What should my approach be like in this case? Any suggestions?
"leave the calculation within working hours" the valid interval (working time), has to be filtered in the
where
– Ricardo Pontual
Do you have the schedule of the preview in your table? Could you guess the structure of the table of appointments and some examples of content?
– William John Adam Trindade
The hours of attendance is that set above 8hs to 18hs, my question is whether for example I "pause" an appointment today at 17hs and resume tomorrow at 8hs, count only 1 hour of break, and not 15 as occurs today.
– Valdir Silva
I edited again now with some fictitious table data for a better understanding of the problem.
– Valdir Silva