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 2000 Forums
 SQL Server Development (2000)
 conversion of integer into time format in sql

Author  Topic 

manu
Starting Member

41 Posts

Posted - 2005-10-17 : 09:18:22
hello,

i want to convert integer into time format.

suppose i have 600 ( seconds) in a field then i want to display it
as (00:10:00) as a result of sql query.

Pls help

Munish Gupta

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-10-17 : 09:26:00
select convert(varchar(10), dateadd (s, 600, '19000101'), 108)

but formating should be done at presentation layer

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-17 : 09:26:53
If you use Front End Application use this type of calculation there
Otherwise use this

declare @sec int
set @sec=600
select convert(varchar(5),@sec/3600)+':'+convert(char(2),@sec%3600/60)+':'+convert(char(2),(@sec%60))


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-17 : 09:27:59
>>select convert(varchar(10), dateadd (s, 600, '19000101'), 108)

Perfect

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

manu
Starting Member

41 Posts

Posted - 2005-10-17 : 09:41:13
Yes sir,

it is working properly.

thanks a lot for your help.


Munish Gupta
Go to Top of Page
   

- Advertisement -