Results 1 to 5 of 5

Thread: Time A - Time B

  1. #1
    Join Date
    Jan 2002
    Posts
    165

    Unanswered: Time A - Time B

    Business process start at time B, for example, 2009-12-08 10:48:11 and ended at time A, for example, 2009-12-08 10:49:53.
    I have to calculate "time A-time B" and want a result in format hh:mi:ss.
    Unfortunately, time A - time B is of type float, and typically is sth like
    0.0013975.

    How to get 0.0013975 in format 'hh:mi:ss'?

    Thanks in advice, Zvonimir

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Result of DATE subtraction is "number of days". Now that you know that "time A - time B" gives days, it is a matter of calculation to transform it into any format you want (1 day = 24 hours, 1 hour = 60 minutes, 1 minute = 60 seconds, ...).

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    For differences of less than 1 day, this will also work:
    Code:
    SQL> select to_char(date '1900-01-01'+0.0013975, 'HH24:MI:SS') from dual;
    
    TO_CHAR(
    --------
    00:02:01

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Nice trick !!!

  5. #5
    Join Date
    Jan 2002
    Posts
    165
    Thnx a lot for Your advice, very good trick

Posting Permissions

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