Whole convert in hours / minutes

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
jerry-sc
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 45
Joined: Tue, 01 Nov 2011 1:24 pm

Good afternoon.

I have a field in my database, which is an integer that records time / minutes. Someone knows how I could convert this whole for hours / minutes (in 24h format).
I have a field, for example that it records the number 782, which actually represents within the system the hour 13:02.

If someone has any idea, or have already worked with whole conversion to time / minutes, thank you.

Thanks.
DanielNN
Moderador
Moderador
Posts: 641
Joined: Mon, 03 Sep 2007 3:26 pm
Location: Fortaleza - CE
att,

Daniel N.N.

In fact your data record stores the number of minutes that for reporting reasons you intend to display.

The following function has this purpose. I hope you answer.

Select all

CREATE OR REPLACE FUNCTION get_hours_from_min_f 
  ( 
    p_minutes NUMBER 
  ) RETURN VARCHAR2 IS 
 
ln_hours    NUMBER; 
ln_minutes  NUMBER; 
lv_return   VARCHAR2(10); 
 
BEGIN 
   ln_hours   := TRUNC(p_minutes/60); 
   ln_minutes := MOD(p_minutes,60); 
 
   lv_return  := ln_hours || ':' || LPAD(ln_minutes,2,'0'); 
   RETURN lv_return; 
END;
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests