同样的格式化时间sql,在同一台客户端的pl/sql ,正式数据库可以运行,测试数据库不能运行;
为10.2.0.1.0版本;测试数据库(windows操作系统)报ORA-01861:文字与格式字符串不匹配,正式数据库(liunx系统)OK,select * from tab where to_date(b.dddd,'yyyy-mm-dd hh24:mi:ss')
  between  to_date(to_char(sysdate-1,'yyyy-mm-dd')||' 00:00:01','yyyy-mm-dd hh24:mi:ss')
  and to_date(to_char(sysdate-1,'yyyy-mm-dd')||' 23:59:59','yyyy-mm-dd hh24:mi:ss')

解决方案 »

  1.   

    正式数据库和测试数据库,两个的日期格式可能不符合!
    select sysdate from dual;
    show parameter nls_date_format
    select name,value from v$sys_parameter where name='NLS_DATE_FORMAT';alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss'
      

  2.   

    windows 的日期格式可能跟你的有出入 
      

  3.   

    试试这样还报错么
    select * 
      from tab 
     where to_date(b.dddd,'yyyy-mm-dd hh24:mi:ss')
           between trunc(sysdate-1) and trunc(sysdate)-1/24/60/60
      

  4.   

    还有就是确认下dddd字段的内容是不是都符合'yyyy-mm-dd hh24:mi:ss'的格式.