日期:2014-05-17 浏览次数:20733 次
SQL> select HIREDATE from emp e where e.hiredate 2 between to_date('1980-1-1','yyyy-mm-dd') and to_date('1981-1-1','yyyy-mm-dd') 3 / HIREDATE ----------- 1980-12-17
------解决方案--------------------
SQL> select * from t3 2 where to_date(installationdate,'yyyy-mm-dd') between '2008-05-01' and '2008-05-08'; select * from t3 where to_date(installationdate,'yyyy-mm-dd') between '2008-05-01' and '2008-05-08' ORA-01861: literal does not match format string SQL> SQL> select * from t3 2 where to_date(installationdate,'yyyy-mm-dd') 3 between to_date('2008-05-01','yyyy-mm-dd') and to_date('2008-05-08','yyyy-mm-dd'); INSTALLATIONDATE ------------------------------ 2008-05-01 SQL> select * from t3; INSTALLATIONDATE ------------------------------ 2008-06-01 2008-05-01 2008-06-01
------解决方案--------------------
本身DATA类型的不能用to_date
date型的必须和date型的比较,不能和字符型的比较
ORACLE里对DATE型和VARCHAR的比较比SQL SERVER里严格
------解决方案--------------------