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
 General SQL Server Forums
 New to SQL Server Programming
 Convert (int,not null) to HH:MM:SS

Author  Topic 

jmersing
Yak Posting Veteran

57 Posts

Posted - 2011-06-03 : 09:04:40

Im having some difficulty converting a value that looks like this: 73247 into 07:32:47.



I'm using:

CONVERT(VARCHAR,TRLogTime / 60) + ':' + RIGHT('00' + CONVERT(VARCHAR, TRLogTime % 60), 2) AS Time

I think I'm missing something...

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-03 : 09:33:02
stuff(stuff(right('0' + convert(varchar(6),TRLogTime),6),5,0,':'),3,0,':')

Might have the positions on the stuff wrong but easy to fix

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jmersing
Yak Posting Veteran

57 Posts

Posted - 2011-06-03 : 13:53:24
Wow I assumed I would have had to replace "stuff" with something but wasnt sure what it would be so I left it in and it ran!!??

Can you explain why that worked? What is the purpose of "stuff"?

Thanks!!
Go to Top of Page
   

- Advertisement -