ORA-01843 not a valid month- Comparing Dates

前端 未结 9 2223
南方客
南方客 2020-12-15 03:49

I have a problem when try to select data from a table filtering by date.

For example:

SELECT * FROM MYTABLE WHERE MYTABLE.DATEIN = \'23         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 04:45

    In a comment to one of the answers you mention that to_date with a format doesn't help. In another comment you explain that the table is accessed via DBLINK.

    So obviously the other system contains an invalid date that Oracle cannot accept. Fix this in the other dbms (or whatever you dblink to) and your query will work.

    Having said this, I agree with the others: always use to_date with a format to convert a string literal to a date. Also never use only two digits for a year. For example '23/04/49' means 2049 in your system (format RR), but it confuses the reader (as you see from the answers suggesting a format with YY).

提交回复
热议问题