For my call center I need to calculate average talk time and display them in MM:SS. I have the user involvement time in sec, and the total calls handled:
SELECT sum(usersinvolvedtime)/(sum(numansweredprim)+sum(numansweredover))AS 'Avg Handle time(s)'
FROM calltypefifteenmin
WHERE calltypekey IN (229,230,231,232,233,234,888,889,890,891)
and YEAR (recordtimestamp) = '2014'
AND Month (recordtimestamp) = '7'
As a result I get 238. How to convert that into mm:ss ??
Many thanks in advance..!
Edwin
Should be something along the following lines:
DECLARE @secs INT = 238;
SELECT
CONVERT(VARCHAR(8), @secs / 60)
+ ':'
+ RIGHT('0' + CONVERT(VARCHAR(2), @secs % 60), 2);
Try this:
SELECT CAST(238/60 AS VARCHAR) + ':' + CAST(238%60 AS VARCHAR) // 3:58
If you want exactly in MM:SS
format
SELECT RIGHT('0' + CAST(238 / 60 AS VARCHAR),2) + ':' +
RIGHT('0' + CAST(238 % 60 AS VARCHAR),2) // 03:58
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.