By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,609 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,609 IT Pros & Developers. It's quick & easy.

convert duration in seconds to hh:mm:ss

P: n/a
Does anyone have a function to convert duration in seconds to a format
hh:mm:ss

Thanks.

Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
hi****@gmail.com wrote:
Does anyone have a function to convert duration in seconds to a format
hh:mm:ss

Thanks.

TIME('00:00:00') + <blah> seconds

Should do it
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

P: n/a
Thanks Serge.
It provides the time since midnight, where as I need 125 seconds as
00:02:05, now it outputs as 12:02:05
Any tweaks available?

Nov 12 '05 #3

P: n/a
hi****@gmail.com wrote:
Thanks Serge.
It provides the time since midnight, where as I need 125 seconds as
00:02:05, now it outputs as 12:02:05
Any tweaks available?

Local format...let's go ISO:

CREATE FUNCTION formatseconds(sec INT)
RETURNS CHAR(8)
DETERMINISTIC NO EXTERNAL ACTION CONTAINS SQL
RETURN REPLACE(CHAR(TIME('00:00:00') + 125 seconds, ISO), '.', ':');

db2 => values formatseconds(125);

1
--------
00:02:05

1 record(s) selected.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #4

P: n/a
Thanks, It worked.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.