Convert time interval to units of hours

LabKey Support Forum (Inactive)
Convert time interval to units of hours Jon (LabKey DevOps)  2015-12-13 20:24
Status: Closed
 
Hi Will,

Have you tried using the timestampdiff option along with SQL_TSI_HOUR?

Take a look at my SQL code below:

SELECT SupportTickets.Client AS Client,
ROUND(AVG(timestampdiff('SQL_TSI_HOUR', SupportTickets.Created, SupportTickets.Resolved)),2) AS AverageHoursOpenToResolved
FROM SupportTickets
WHERE SupportTickets.Status != 'open' AND SupportTickets.Created >= (curdate() - 7)
GROUP BY SupportTickets.Client

This code specifically identifies the average amount of hours it takes to resolve a ticket by client and then rounds off by two places.

You should be able to do something similar to display your hours similarly.

Reference: https://www.labkey.org/wiki/home/Documentation/page.view?name=labkeysql

Regards,

Jon