BookmarkSubscribeRSS Feed
ashwini2
Fluorite | Level 6

case when status not in ('Cancelled', 'Closed', 'Filled' ) then sysdate
when date_filled < date_req_approved then date_last_status_change else coalesce(date_filled, date_last_status_change)
end as date_filled

 

 

I think the issue is with sysdate.

ERROR: CLI cursor fetch error: [Oracle][ODBC][Ora]ORA-01840: input value not long enough for date format

 

Any suggestions how to make this work?

8 REPLIES 8
kiranv_
Rhodochrosite | Level 12

Are you running pass through. This is more of oracle question but one thing is for sure. columns you are comparing or in coalesce do not have same formats

ashwini2
Fluorite | Level 6

I am running a passthrough. Weirdly my code works just fine in Oracle SQL.

kiranv_
Rhodochrosite | Level 12

Are you running an explicit sql pass through(via connect statement) or an implicit sql

ashwini2
Fluorite | Level 6

I am using the connect statement 

 

proc sql;
connect to odbc as ods

kiranv_
Rhodochrosite | Level 12

if it has worked in oracle sql developer and not working in connect statement. This might be any issue with ODBC connection related issue.

Patrick
Opal | Level 21

@kiranv_

Just Googling the error Oracle throws: It could be that the data types of the columns you're using are not all of type DATE and that some implicit conversion is happening. If such implicit conversion is going on then Oracle will use the format as set in NLS_DATE_FORMAT. If this format doesn't match the string it's trying to convert then you could get the Oracle error you observing.

Following this thought: It's possible that NLS_DATE_FORMAT has a different value depending on how you connect to Oracle (via SAS or SQL Developer). 

 

What I would do:

1. Check if all your data types are DATE

2. If not all columns of type DATE: Cast strings to date using an explicit format using the to_date() function. Don't rely on implicit conversions.

SuryaKiran
Meteorite | Level 14

Make sure that all these variable(sysdate, date_last_status_change, date_filled, date_last_status_change) have same date or datetime formats. 

 

If your sysdate is 'DD/MM/YYYY 00:00:00' format and date_last_status_change is 'DD/MM/YYYY' format, then you might get this possible error. Convert them to same format using TO_DATE() in Oracle or convert them all to characters using TO_CHAR.

Thanks,
Suryakiran

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 10551 views
  • 1 like
  • 5 in conversation