Is there any tricky way to format seconds like hours:minutes:seconds. For example,
3660
seconds will be displayed as
01h 01m 00s
or
01:01:00
I am aware of the standard way of doing this:
I met the following issues:
I am not able to create separate function that do this.
My code is in view using several CTEs. So, variables can be declare using the CTEs only.
SELECT RIGHT('00'+CONVERT(VARCHAR(10),Seconds/3600),2)
+':'
+ RIGHT('00'+CONVERT(VARCHAR(2),(Seconds%3600)/60),2)
+':'
+ RIGHT('00'+CONVERT(VARCHAR(2),Seconds%60),2) AS [HH:MM:SS]
FROM table1
Result:
HH:MM:SS |
---|
01:01:00 |
01:03:20 |
01:10:00 |
00:10:00 |
00:01:00 |
00:00:30 |
24:00:00 |
24:06:40 |