Time diff in Hrs..
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Time diff in Hrs..

  1. #1
    Join Date
    Feb 2002
    Posts
    5
    Hi,

    Can anybody help me in this regard.

    I have two date columns in a table like start_date and end_date

    I want to find the diff between these two dates and get the result in number of hours.

    I want the result in a single select statement.

    Thanks,
    Muralee

    [Edited by muralees on 02-28-2002 at 04:08 PM]

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    select round((date_end- date_start) * 24,0) hours_diff from dual;

  3. #3
    Join Date
    Apr 2001
    Posts
    45
    Hi Muralees:

    Try this:


    select (end_date-start_date)*24 from table;

    i.e


    select (to_date('01-jan-02,'dd-mon-yy')-to_date('30-dec-01','dd-mon-yy'))*24 hrs from dual;

    will return 48 hrs.

    hth
    may$e

  4. #4
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    1,185
    If you store the time at the Seconds level of granularity, you can use the fact that there are 3600 seconds per hour, and find the difference, do the division, and get your result.

    Good luck.
    David Knight
    OCP DBA 8i, 9i, 10g

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