DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: number in hour format

  1. #1
    Join Date
    Nov 2000
    Posts
    440

    number in hour format

    I have a query that return number.

    1.15
    0.36
    10.10


    i want them in time format like
    1h 9 min
    0h 22 min
    10h 6 min

    anyone?

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    For 1.15

    SQL> L
    1 select trunc(:b1) ||' Hr '|| round((((:b1*100) - (trunc(:b1)*100))*60/100),0) ||' Mi' "Time"
    2* from dual
    /

    Time
    ----------
    1 Hr 9 Mi


    Tamil
    Last edited by tamilselvan; 01-18-2006 at 12:24 PM.

  3. #3
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    A little less "wordy" ...
    Code:
    SQL> select Trunc(1.15) ||' Hr '|| Mod(1.15,1)*60 ||' Mi' "Time"
      2  from   dual
      3  /
    
    Time
    ---------
    1 Hr 9 Mi
    If you have to deal with negatives then:
    Code:
    SQL> select Trunc(-1.15) ||' Hr '|| Mod(Abs(-1.15),1)*60 ||' Mi' "Time"
      2  from   dual
      3  /
    
    Time
    ----------
    -1 Hr 9 Mi
    (Note the ABS function)
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width