1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
CREATE FUNCTION fx_length ( @Seconds INT ) RETURNS VARCHAR(8) AS BEGIN IF @Seconds < 60 BEGIN RETURN '00:00:'+RIGHT('00'+CONVERT(VARCHAR,@Seconds),2) END DECLARE @Min INT SET @Min = @Seconds / 60 SET @Seconds = @Seconds % 60 IF @Min < 60 BEGIN RETURN '00:'+RIGHT('00'+CONVERT(VARCHAR,@Min),2)+':'+RIGHT('00'+CONVERT(VARCHAR,@Seconds),2) END DECLARE @Hour INT SET @Hour = @Min / 60 SET @Min = @Min % 60 RETURN RIGHT('00'+CONVERT(VARCHAR,@Hour),2)+':'+RIGHT('00'+CONVERT(VARCHAR,@Min),2)+':'+RIGHT('00'+CONVERT(VARCHAR,@Seconds),2) END |
Wednesday, April 2, 2014
MSSQL: Convert Seconds to '00:00:00' Format.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment