Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Convert Number in HH:mm:ss

Author  Topic 

giannilionetti
Starting Member

3 Posts

Posted - 2013-01-17 : 05:41:55
I need to Convert a number without decimal in HH:mm:ss

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-17 : 05:52:58
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

52326 Posts

Posted - 2013-01-17 : 05:53:58
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

52326 Posts

Posted - 2013-01-17 : 05:57:23
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

22864 Posts

Posted - 2013-01-17 : 06:05:10
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
   

- Advertisement -