DECLARE @seconds INT
DECLARE @hours INT
DECLARE @minutes INT
--
SET @seconds = 3661
SET @hours = FLOOR(@seconds/(60*60))
SET @minutes = FLOOR((@seconds - (@hours*3600))/60)
--
SELECT
RIGHT('0' + CONVERT(VARCHAR(2), @hours), 2) +
':' +
RIGHT('0' + CONVERT(VARCHAR(2), @minutes), 2)
-----
01:01
(1 row(s) affected)
Man könnte allerdings auch:
SET @secs = 3661
SELECT CONVERT(VARCHAR(5), DATEADD(SECOND, @secs, '00:00'), 108)
-----
01:01
(1 row(s) affected)
verwenden.