0

I' am having this error:

 ORA-01861: literal does not match format string
    01861. 00000 -  "literal does not match format string"
    *Cause:    Literals in the input must be the same length as literals in
               the format string (with the exception of leading whitespace).  If the
               "FX" modifier has been toggled on, the literal must match exactly,
               with no extra whitespace.
    *Action:   Correct the format string to match the literal.

It happened overnight without any changes in the database configuration. It looks like there is a problem with sysdate format but I'm not 100% sure. We have many places in our procedures where we use to_date(to_char(sysdate, 'YYYY-MM-DD')) from dual which actually breaks. Is there any way to format sysdate to match the following expression?

to_date(to_char(sysdate, 'YYYY-MM-DD')) from dual
3

First you convert sysdate to a char type, then you convert it back to a date type without specifying the format string, which may or may not work based on the settings of the session running this code.

This is completely unnecessary, just use trunc(sysdate) to remove the hours, minutes and seconds.

Also, if you return a date type, then the format depends on the nls_date_format variable, not the SQL that produces the date value.

|improve this answer|||||
  • @DominykasČesonis if Balazs's answer didn't help, then you aren't showing us all the information. trunc(sysdate) wouldn't give you the same error message. I suggest you edit your question to include the full query (change the table/column names and/or literals as appropriate to mask your structure). – Boneist Feb 18 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.