Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert number to time

Tags:

sql

oracle

How to convert number 1.33408564814814 to time 32:01:05?

like image 443
DejanL Avatar asked Dec 07 '22 01:12

DejanL


1 Answers

If you actually want the result as a character string, you could use a function like this:

set serveroutput on format wrapped;

declare
function days_to_time (p_days number) return varchar2
is
  d number := p_days;
  h integer;
  m integer;
  s integer;
begin
  h := trunc(d*24);
  d := d - h/24;
  m := trunc(d*24*60);
  d := d - m/24/60;
  s := round(d*24*60*60);
  return(h||':'||to_char(m,'FM00')||':'||TO_CHAR(s,'FM00'));
end;
begin
  dbms_output.put_line(days_to_time(1.33408564814814));
end;
/

anonymous block completed
32:01:05
like image 184
Tony Andrews Avatar answered Dec 09 '22 13:12

Tony Andrews