oracle中日期格式'yyyy-mm-dd'和'yyyymmdd'的区别

对于年月日中"日"是个位的情况下,处理不一样,'yyyymmdd'格式没问题,而式'yyyy-mm-dd'格式则不行,请看:

SQL> alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select to_date('2007059','yyyy-mm-dd hh24:mi:ss') from dual;
select to_date('2007059','yyyy-mm-dd hh24:mi:ss') from dual
                 *
ERROR at line 1:
ORA-01861: literal does not match format string


SQL> select to_date('2007059','yyyy-mm-dd') from dual;
select to_date('2007059','yyyy-mm-dd') from dual
                 *
ERROR at line 1:
ORA-01861: literal does not match format string


SQL> select to_date('2007059','yyyymmdd')   from dual;

TO_DATE('2007059','

posted @ 2015-12-09 11:34  华丽》》转身  阅读(1400)  评论(0编辑  收藏  举报