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

Thread: tell me the Date Diff function in Oracle

  1. #1
    Join Date
    Mar 2001
    Posts
    6

    Question

    Hi Guys,

    I wanna difference of two dates. How can i do woth Oracle...
    Help Me soon...


    Thanx for advance guys...

    With
    Venkat

  2. #2
    Join Date
    Mar 2001
    Posts
    17
    You can use INTERVAL function.
    This function Subtracts one datetime from another and generates the result.
    When you add or subtract one interval from another, the result
    is always another interval. You can multiply or divide an interval
    by a numeric constant.
    e.g.1
    SELECT sysdate - INTERVAL '8' MONTH FROM DUAL;
    Returns the following result:
    SYSDATE-I
    ---------
    28-JUL-00

    e.g.2
    SELECT sysdate - INTERVAL '8' day FROM DUAL;
    Returns the following result:
    SYSDATE-I
    ---------
    20-MAR-01

    e.g.3
    SELECT sysdate - INTERVAL '8' year FROM DUAL;
    Returns the following result:
    SYSDATE-I
    ---------
    28-MAR-93

    OR
    you can directly subtract one date from another to get difference but you need to
    multiply or divide by a proper numeric constant.

    Hope this will solve your problem

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    By subtracting two dates, you will get the difference in days. For example,
    system@dev815nt.us> l
    1 select sysdate - to_date('01/01/2001','mm/dd/yyyy') days
    2* from dual
    system@dev815nt.us> /

    DAYS
    ----------
    86.3983333
    Jeff Hunter

  4. #4
    Join Date
    Mar 2001
    Posts
    5

    Angry date diff

    You could use the months_between function

    for example

    select months_between(sysdate,'12-aug-00') from dual;

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