且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将数字转换为时间

更新时间:2023-02-03 16:53:44

如果您实际上希望将结果作为字符串,则可以使用如下函数:

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