6

I don't know if it's a bug or what, but when I try to format the Day of the week in a certain way with the to_char function in Oracle, SQL Plus give me this error : ORA-01821: date format not recognized

Here's the line that cause a problem

SELECT TO_CHAR(sysdate,'dsp') from dual;

So d is of 'Day of the week' and sp is for spell. This line should print five because we are thursday.

It's weird because this next line worked

SELECT TO_CHAR(sysdate,'ddsp') from dual;

dd is for 'Day of the month' so sql plus printed twenty-nine without any problem!!

Can someone tell me why this line is not working?

Thanks..

Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235
Joel
  • 339
  • 2
  • 11

1 Answers1

3

If you must make this work, here's an ugly workaround:

SELECT to_char(to_date(to_char(SYSDATE,'d'),'j'),'jsp') FROM dual;

Looks like a bug to me...

DCookie
  • 42,630
  • 11
  • 83
  • 92