Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a value from seconds to HH:MM:SS format 1

Status
Not open for further replies.

cplsplsprogrammer

Programmer
Apr 18, 2005
42
US
Hello all,

Can anyone please tell me how can I convert a value from seconds to HH:MM:SS format in sql server? I am using sql server 2000. Do I need to write a user defined function for it? or is there any built in function that I can use? I tried to use the "convert" but it didnt work. I used it as

convert( int, "value", 108) but it is returning the same value as given. Can anyone please tell me how can i proceed.

Thanks.
 
Convert number of seconds to datetime (by using dummy zero date), then use 108 format:
Code:
declare @s int; set @s = 32145
select convert(varchar(8), dateadd(ss, @s, 0), 108)

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top