Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle 9iDS converting Minutes to Hour and Minutes

Status
Not open for further replies.

rrrkrishnan

Programmer
Jan 9, 2003
107
US
Hi,

I am trying to convert minutes to Hour and Minutes through PL/SQL, for exmple 6 minutes should be shown as 0 Hr and 6Mins.

Any idea as how to do this?

Thanks!


 
Something like:
Code:
CREATE OR REPLACE FUNCTION hrs_minutes(p_minutes IN NUMBER)
RETURN VARCHAR2 IS
   l_hours NUMBER;
BEGIN
   l_hours := trunc(p_minutes/60);
   RETURN to_char(l_hours)||' Hr and '||to_char(p_minutes - 60*l_hours)||'Mins';
END;
/
would give you a reusable version. Then you would get results like:
Code:
13:31:29 SQL> select hrs_minutes(6) from dual;

HRS_MINUTES(6)
---------------------------------------------------------
0 Hr and 6Mins

13:31:38 SQL> select hrs_minutes(60) from dual;

HRS_MINUTES(60)
---------------------------------------------------------
1 Hr and 0Mins

13:31:44 SQL> select hrs_minutes(650) from dual;

HRS_MINUTES(650)
---------------------------------------------------------
10 Hr and 50Mins
 
select trunc:)minutes/60)||' Hr '|| :)minutes-trunc:)minutes/60)*60)||' Mins' from dual
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top