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 01840 input value not long enough for date format

479619Feb 7 2006 — edited Feb 7 2006
Hello,

I have a query that I am working on that is designed to see if sysdate is approaching a stored date plus 29 months. For example, today's date is 02/07/2006. My stored date is 10/19/2003. I adjust both dates to the 1st of the corresponding month (02/01/2006, 10/01/2003). Then I add 1 month to sysdate to make is 03/01/2006 and 29 months to the stored date to make it 03/01/2006. Since these two dates are the same, it pull the employee.

Now with the query I made it come up with this error:
"ORA 01840 input value not long enough for date format"

The query:
select e.ssn,
trunc(ADD_MONTHS(ecd.date_2,29))

from employee e,
emp_cg_data ecd

where e.control_id = ecd.control_id
and e.ssn = ecd.ssn
and e.controlled_group_status = 'Y'
and trunc(ADD_MONTHS(to_date('01'||to_char(sysdate ,'mmyyyy'),'ddmmyyyy'),1 )) >= trunc(ADD_MONTHS(to_date('01'||to_char(ecd.date_2 ,'mmyyyy'),'ddmmyyyy'),29))
;

I've been able to narrow it down to this line:
"trunc(ADD_MONTHS(to_date('01'||to_char(ecd.date_2 ,'mmyyyy'),'ddmmyyyy'),29))"

but I'm unsure as to why it is incorrect because when I comment out the compare statement and place this particular line in the select portion then it outputs the date fine. I'm curious if it has something to do with trying to compare with all the formatting in there. Also, if I leave the formatting of the the sysdate and compare it to a hard date then it runs fine, but if I compare a hard date to the formatting of date_2 then it gives me that same error. Any ideas?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 7 2006
Added on Feb 7 2006
7 comments
1,726 views