I have a select query that has DURATION column to calculate number of Minutes . I want to convert those minutes to hh:mm format.
Duration has values like 60, 120,150
For example: 510 becomes 08:5 hours
select ISNULL(CONVERT(VARCHAR,CONVERT(INT,510)/60)+':'+ RIGHT('0'+CONVERT(VARCHAR,CONVERT(INT,510)%60),2),0) AS TotalHour
How to convert number of minutes to hh:mm format in TSQL?
DECLARE @tm INT; SELECT @tm =SUM(tm) FROM ( SELECT 60 AS tm UNION SELECT 120 UNION SELECT 150 )AS hm SELECT format(DATEADD(MINUTE,@tm,CAST(CAST(0 AS FLOAT) AS DATETIME)),'HH:mm');
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)