Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

oracle - Convert minutes to HH24:MI format

Can you please help in converting minutes to the format of ('HH24:MI').

I am getting the result in integer which is the minutes. So, how to convert them?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Assuming, you want to convert 492 minutes:

select to_char(trunc(sysdate) + 492/24/60, 'hh24:mi') from dual;

If you want a function:

create or replace 
  function tq84_convert_minutes_hh24mm (p_minutes in number) 
  return varchar2 is
begin

    return to_char (trunc(sysdate) + p_minutes / 24/60, 'hh24:mi');

end tq84_convert_minutes_hh24mm;
/

Later ...

begin
  dbms_output.put_line (tq84_convert_minutes_hh24mm(492));
end;
/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...