以下查询给出错误:
SELECT to_char(last_day(add_months(to_char(to_date('01-02-2013','dd-mm-yyyy'),
'dd-MON-yyyy'),-1)) + 1,'dd-mm-yyyy') FROM dual;
ORA-01858: a non-numeric character was found where a numeric was expected
我在两个系统上试过这个:
使用 NLS_DATE_FORMAT='DD-MON-RR' - 此查询工作正常。
使用 NLS_DATE_FORMAT='MM-DD-YYYY' - 给我错误
ORA-01858: a non-numeric character was found where a numeric was expected
。
关于此查询为何失败的任何线索?我不能让查询依赖于 DATE 格式。