Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Posts
    7

    Unanswered: Calculating date differences

    select to_date('12-11-2010', 'DD-MM-YYYY') - to_date('30-10-2010', 'DD-MM-YYYY') dif_dies
    from dual;

    I need to know the difference of two dates that are pased as parameteres to a procidemnt.

    Like:
    12/10/2010 17/10/2010
    dia_multa dia_pagament

    I have trying and searching some things but i cant get it. This is the line im was actually testing:

    select to_date(dia_multa) - to_date(dia_pagament) into difint from dual;

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >select to_date(dia_multa) - to_date(dia_pagament) into difint from dual;
    If they are really DATE datatypes then do as below

    select dia_multa - dia_pagament difint from dual;

    BTW, the INTO clause is only valid in PL/SQL; not plain SQL.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    May 2011
    Posts
    7
    i use plsql, anyway, that has to work?

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Feb 2004
    Location
    Chennai
    Posts
    53
    r u getting any error? u may have to specify a format specifier for to_date
    -Mathan
    For a quick pocket reference of oracle refer http://pocketoracle.blogspot.com/

Posting Permissions

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