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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Convert Number in HH:mm:ss
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

giannilionetti
Starting Member

3 Posts

Posted - 01/17/2013 :  05:41:55  Show Profile  Reply with Quote
I need to Convert a number without decimal in HH:mm:ss

James K
Flowing Fount of Yak Knowledge

3585 Posts

Posted - 01/17/2013 :  05:52:58  Show Profile  Reply with Quote
What is content of the number? is it YYYYMMDDHHmmss or HHmmss or something else? Post some sample data?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 01/17/2013 :  05:53:58  Show Profile  Reply with Quote
just do like example below provided number represents seconds

DECLARE @Number int
SET @Number=234
SELECT CONVERT(varchar(8),DATEADD(ss,@Number,0),108)



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

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 01/17/2013 :  05:57:23  Show Profile  Reply with Quote
also see

http://visakhm.blogspot.in/2010/03/time-difference-function.html

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

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 01/17/2013 :  06:05:10  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
In 2012, you can also do

select format(getdate(),'hh:mm:ss')


Madhivanan

Failing to plan is Planning to fail
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.08 seconds. Powered By: Snitz Forums 2000