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 2005 Forums
 Transact-SQL (2005)
 Return Hour-Minutes-Seconds according seconds

Author  Topic 

klegrand
Starting Member

29 Posts

Posted - 2007-04-06 : 06:02:32
I have a number of seconds.

I need to return this in hours, minutes and seconds.
Example :
1861 seconds is 5 hours, 1 minute and 1 second

Is there a special SQL command for this ?

Thanks a lot...

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-06 : 06:30:35
What? 1861 seconds is 31 minutes and 1 second.

SELECT CONVERT(VARCHAR, DATEADD(SECOND, 1861, 0), 108)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-06 : 06:34:02
18061 is 5 hours, 1 minute and 1 second.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

klegrand
Starting Member

29 Posts

Posted - 2007-04-06 : 06:51:28
Thanks Peter,

That's the instruction that I was looking for...

I forget indeed the '0' in my example ;-)
Go to Top of Page
   

- Advertisement -