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!

Parsing VARCHAR to DATE where the VARCHAR column has multiple format

670102Nov 12 2008 — edited Nov 12 2008
Hello,

I'm a little stumped here so I figured I'd try posting here.

I have an application where I can not alter the code. This application has a form with a calender conrol on it that allows the user to select a date. This form is internationalized so date formats vary based on the country the user is coming form (mm/dd/yyyy, dd-Mon-yyyy, dd.mm.yyyy, etc). The application saved the string of the date as the calender control returns to the form, it does not save the value as a date value.

I need to preform a query that can do some cacluations off of this date. When there is only one date format returned in the query, there is no problem

CASE WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) < 0 THEN calc_business_days(TO_DATE(d3.data,'Mon/dd/yyyy'),NVL(trunc(i3.end_date),trunc(SYSDATE)))
WHEN TO_DATE(d3.data,'Mon/dd/yyyy')-NVL(trunc(i3.end_date),trunc(SYSDATE)) > 0 THEN 0-(calc_business_days( NVL(trunc(i3.end_date),trunc(SYSDATE)) ,TO_DATE(d3.data,'Mon/dd/yyyy')))
ELSE 0 END

However, this errors when there are multiple formats in the varchar column for the same query. Can anyone provide any guidance on how to handle this? I am using Oracle 10g.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2008
Added on Nov 12 2008
7 comments
679 views