Convert Integer in time In Sql Server
Call Function :
Output :
Introduction : In this article i will show you how to convert Integer to time format in sql server .I have created function will return time as a string .Its takes parameter as a second in integer and return time .
CREATE function [dbo].[GetMinutesFromInt](@seconds int) returns varchar(20) as begin declare @time varchar(20) set @time = CASE WHEN @seconds/3600<10 THEN '0' ELSE '' END + RTRIM(@seconds/3600) + ':' + RIGHT('0'+RTRIM((@seconds % 3600) / 60),2) + ':' + RIGHT('0'+RTRIM((@seconds % 3600) % 60),2) return(@time) end
Call Function :
select dbo.GetMinutesFromInt(70)
Output :
00:01:10
Good post ..
ReplyDeleteThanks for sharing it .Keep it up .
Thanks! you save my life....
ReplyDelete