Oracle PL SQL中的格式日期

问题描述 投票:0回答:1

[当我在查询以下返回错误时,我试图学习如何在oracle pl oracle中格式化日期

SELECT TO_DATE('01-JAN-00', 'YYYY-DD-MM') FROM dual;

the error message is

ORA-01858: a non-numeric character was found where a numeric was expected
01858. 00000 -  "a non-numeric character was found where a numeric was expected"
*Cause:    The input data to be converted using a date format model was
           incorrect.  The input data did not contain a number where a number was
           required by the format model.
*Action:   Fix the input data or the date format model to make sure the
           elements match in number and type.  Then retry the operation.
oracle date oracle11g oracle10g oracle-sqldeveloper
1个回答
0
投票

您未使用正确的格式说明符,或未传递正确的字符串。您想要:

SELECT TO_DATE('2000-01-01', 'YYYY-DD-MM') FROM DUAL;

或:

SELECT TO_DATE('01-JAN-00', 'DD-MON-YY') FROM DUAL;

或者您也可以简单地声明DATE垃圾:

SELECT DATE'2000-01-01' FROM DUAL;
© www.soinside.com 2019 - 2024. All rights reserved.