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-01839: date not valid for month specified

602365Sep 2 2008 — edited Sep 3 2008
The following code was working correctly, until September kicked in....

Now I get ORA-01839: date not valid for month specified

Any one know why?

DECLARE
QA1 DATE;
QA2 DATE;
QB1 DATE;
QB2 DATE;
QC1 DATE;
QC2 DATE;
QD1 DATE;
QD2 DATE;
c_date DATE;

BEGIN

select current_date INTO c_date from DUAL;

IF c_date between to_date('01-JUN', 'DD-Mon') AND to_date('31-AUG', 'DD-Mon') then
QD1 := to_date('01-JUN', 'DD-Mon');
QD2 := to_date('31-AUG', 'DD-Mon');

ELSIF c_date between to_date('01-SEP', 'DD-Mon') AND to_date('31-NOV', 'DD-Mon') then
QD1 := to_date('01-SEP', 'DD-Mon');
QD2 := to_date('31-NOV', 'DD-Mon');

ELSIF c_date between to_date('01-DEC', 'DD-Mon') AND to_date('29-FEB', 'DD-Mon') then
QD1 := to_date('01-DEC', 'DD-Mon');
QD2 := to_date('29-FEB', 'DD-Mon');

ELSIF c_date between to_date('01-MAR', 'DD-Mon') AND to_date('31-MAY', 'DD-Mon') then
QD1 := to_date('01-MAR', 'DD-Mon');
QD2 := to_date('31-MAY', 'DD-Mon');

END IF;

QC1 := ADD_MONTHS(QD1,-3);
QC2 := ADD_MONTHS(QD2,-3);
QB1 := ADD_MONTHS(QD1,-6);
QB2 := ADD_MONTHS(QD2,-6);
QA1 := ADD_MONTHS(QD1,-9);
QA2 := ADD_MONTHS(QD2,-9);

END;

Cheers,

S
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2008
Added on Sep 2 2008
8 comments
1,450 views