[Hint] Convert seconds to hour minute and Sec

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc

Poston Tue, 09 Aug 2005 4:20 pm

See this:
Code: Select all
select to_char(trunc(:seg/60/60),'09') ||
to_char(trunc(mod(:seg,3600)/60),'09') ||
to_char(mod(mod(:seg,3600),60),'09') hh_mm_ss
from dual;
He converts x number of seconds into HH MM SS. Let's go to example:
Code: Select all
SQL> variable seg number
SQL> exec :seg := 3000;

PL/SQL procedure successfully completed.

SQL> select to_char(trunc(:seg/60/60),'09') ||
  2  to_char(trunc(mod(:seg,3600)/60),'09') ||
  3  to_char(mod(mod(:seg,3600),60),'09') hh_mm_ss
  4  from dual;

00 50 00

i.e. 3000 seconds = 50 minutes.
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?

Poston Mon, 01 Dec 2008 8:21 am

Very Good helped me a lot, thanks! :-o
Location: Minas Gerais

  • See also
    Last Post

      Return to SQL

      Who is online

      Users browsing this forum: No registered users and 9 guests