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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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