Minuten in Stunden umwandeln

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.

 

Noch kein Feedback
Einen Kommentar hinterlassen

Ihre E-Mail-Adresse wird nicht auf dieser Seite angezeigt.
SchlechtExzellent
(Zeilenumbrüche werden zu <br />)
(For my next comment on this site)
(Allow users to contact me through a message form -- Your email will not be revealed!)
Trackback-Adresse für diesen Eintrag

http://www.insidesql.org/blogs/htsrv/trackback.php?tb_id=1108