Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01867: the interval is invalid

1061995Dec 25 2013 — edited Dec 26 2013

Hi All,

Good morning!

Recently i have come across the below error and i need your help on understanding where i am missing:

Error report:

ORA-01867: the interval is invalid

ORA-06512: at line 6

01867. 00000 -  "the interval is invalid"

*Cause:    The character string you specified is not a valid interval.

*Action:   Please specify a valid interval.

Description:

=========

When I use the below piece of code i got the above specified error.

DECLARE

   v_dt_iy2m   INTERVAL YEAR TO MONTH;

   x_dob       DATE                           := '07-JUN-1987';

   x_today     DATE                           := '26-DEC-2013';

BEGIN

  v_dt_iy2m :=

         TO_CHAR (EXTRACT (YEAR FROM x_today) - EXTRACT (YEAR FROM x_dob))

      || '+'

      || TO_CHAR (EXTRACT (MONTH FROM x_today)

      -  EXTRACT (MONTH FROM x_dob));

   DBMS_OUTPUT.put_line (v_dt_iy2m);

END;

here i have noted down that when i use '+' operator in the CONCATENATION function system throws the error, Whereas if i use '-' (minus) symbol, the above code just works fine.

Can someone please assist me what am i am missing/misunderstanding here?

Thanks,

Thiru.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 23 2014
Added on Dec 25 2013
2 comments
5,615 views