Re: Formatting seconds in MM:SS

From: Charles Hooper <hooperc2000_at_yahoo.com>
Date: Fri, 29 Feb 2008 07:49:39 -0800 (PST)
Message-ID: <cf758252-e72a-4f49-aacb-94c2a9daba3c@s8g2000prg.googlegroups.com>


On Feb 29, 9:32 am, Jens Riedel <Jens..._at_gmx.de> wrote:
> Hi,
>
> I need to display a number of seconds in the <minutes>:<seconds>
> notation, e.g. 100 seconds shall return '01:40'.
> Hours shall NOT be displayed, so for example 7201 seconds shall return
> '120:01', not '02:00:01'...
>
> Has anyone a hint how I can achieve this?
>
> Thanx and best regards,
> Jens

It looks like David Fitzjarrell has provided a much more easy to follow solution, but here is something that you can experiment with: SELECT

  TO_CHAR(SYSDATE,'HH24:MI:SS') CTIME,
  TO_NUMBER(TO_CHAR(SYSDATE,'HH24'))*60 TEST1,
  TO_NUMBER(TO_CHAR(SYSDATE,'MI')) TEST2,
  TO_CHAR(SYSDATE,':SS') TEST3

FROM
  DUAL; CTIME TEST1 TEST2 TES
-------- ---------- ---------- ---
10:43:33 600 43 :33

Just add TEST1 to TEST2, convert the result using TO_CHAR, and append TEST3 using ||
643:33

Charles Hooper
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc. Received on Fri Feb 29 2008 - 09:49:39 CST

Original text of this message