SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

asobreiro
Starting Member

2 Posts

Posted - 12/20/2012 :  14:26:44  Show Profile  Reply with Quote
hello
how do you make a function to convert seconds into hours, minutes and seconds???

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 12/20/2012 :  14:34:24  Show Profile  Reply with Quote

CREATE FUNCTION GetTime
(
@Seconds int
)
RETURNS varchar(100)
AS
BEGIN
DECLARE @TimeVal varchar(100),@dateVal datetime

SET @dateVal = DATEADD(ss,@Seconds,0)
SET @TimeVal = CAST(DATEDIFF(dd,0,@dateVal)* 24 +  DATEPART(hh,@dateVal) AS varchar(5)) + ':' + DATENAME(n,@dateVal) + ':' + DATENAME(ss,@DateVal)  

RETURN @TimeVal
END




------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Edited by - visakh16 on 12/20/2012 14:48:46
Go to Top of Page

asobreiro
Starting Member

2 Posts

Posted - 12/20/2012 :  15:14:35  Show Profile  Reply with Quote
Thank you very much
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52323 Posts

Posted - 12/21/2012 :  00:46:49  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000