Solved

Date Formatting Issue

Posted on 2013-06-18
4
384 Views
Last Modified: 2013-06-18
Hi All,

I need your assistance.

I have the below code in a query but I get the an error due to date formatting.

Can anyone please help?


case
when to_date(:p_Enter_Date,'DD/MMM/YY') - MAX(st.sales_date)   > 180 –180 days
then 'Y'
else 'N'
END                                                               as Late_Sales_Payment


ORA-01821: date format not recognized
01821. 00000 -  "date format not recognized"
0
Comment
Question by:jose11au
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 39258399
Use to_date(:p_Enter_Date,'DD/MON/YY')

See here for all supported date formats
0
 

Author Comment

by:jose11au
ID: 39258423
Hi All,

I forgot to explain what I am trying to archive in above case statement

If :p_Enter_Date- MAX(fx.entry_date) > 180 days then 'Y' else 'N'

Thanks
0
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 39258436
You should be fine with your statement (I guess " - 180 days" was just a comment). Just fix the format.

case
when to_date(:p_Enter_Date,'DD/MON/YY') - MAX(st.sales_date)   > 180
then 'Y'
else 'N'
END                                                               as Late_Sales_Payment

Open in new window


BTW, "MON" format is for abbreviated month name, like Jan, Feb,  Mar, etc.
If your p_Enter_Date takes another format (i.e dd/mm/yyyy) you need to use 'DD/MM/YYYY'.

BTW, did you know, that format mask part of this function is optional. You could just use to_date(:p_Enter_Date) and let Oracle to figure out what the user has entered. It is not a bulletproof option, but it will work for any fancy format users may come up with
0
 

Author Comment

by:jose11au
ID: 39258447
Thanks so much, no more error.

Cheers
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now