Posted by: R Manimaran | February 14, 2007

Convert Sec to Hours:min in Sql Server 2000

I look for the Function to convert Seconds to Hours:min in sql server. But I did not get the Result. So i come with the Solution with user-defiined Function.and here is the Function.

CREATE FUNCTION dbo.SecToHours( @TotSec int)
RETURNS varchar(15)  AS 
BEGIN
declare @Sec decimal
declare @mins decimal
declare @Hours int
Select @mins=(@TotSec %60)
Select @Hours=@TotSec/60
return Convert(varchar(5),@Hours) +”:”+Convert(varchar(5),@mins)
END

If u give
Select dbo.SecToHours(80) u get 1:20 as output.
 

Advertisements

Responses

  1. Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

  2. Hi !!!! ^_^
    My name is Piter Kokoniz. oOnly want to tell, that I like your blog very much!
    And want to ask you: will you continue to post in this blog in future?
    Sorry for my bad english:)
    Thank you!
    Piter.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: