View Thread
 Print Thread
Function to format secons to hours and minutes
admin
Example: converts bigint 3601 to varchar "1h1m"


USE [db_CallLogging]
GO

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER OFF
GO

/*
Formats the estimated time in seconds as a time duration in hours and minutes
*/

CREATE FUNCTION [dbo].[format_seconds] ( @Time BIGINT )
RETURNS VARCHAR(20)
AS
    BEGIN
        DECLARE @Time_Varchar VARCHAR(20)
        SET @Time_Varchar = CONVERT(VARCHAR, @Time / 3600) + 'h ' + CONVERT(VARCHAR, ROUND(( ( CONVERT(FLOAT, ( @Time % 3600 )) ) / 3600 ) * 60, 0)) + 'm'
        RETURN @Time_Varchar
    END
GO

Jordon Pilling | Heavencore Administrator
 
Jump to Forum