Bootstrap

当oracle出现 格式与字符串格式不匹配解决办法

    select v.spid spid,v.appid appid,v.version version,v.newversion newversion,v.status status,v.createtime createtime from adc_spversionchangeapply v inner join adc_application a on a.id=v.appid
    where a.create_by = 'a' and v.appid = '12000000005' and  (v.createtime >= '1987-05-06') and (v.createtime <= '2009-04-29')

 

加入v.createtime在数据库中试date类型  那么会跑出异常

 

ORA-01861: 文字与格式字符串不匹配

 

 

实际上是因为 '1987-05-06'是字符串类型导致的date类型与字符串类型 件跨类型比较 所以是有问题的

将'1987-05-06'  写成to_date('1987-09-18','yyyy-mm-dd')

就行了

代码如下

    select v.spid spid,v.appid appid,v.version version,v.newversion newversion,v.status status,v.createtime createtime from adc_spversionchangeapply v inner join adc_application a on a.id=v.appid
    where a.create_by = 'a' and v.appid = '12000000005' and  (v.createtime >= to_date('1987-05-12','yyyy-mm-dd')) and (v.createtime <= to_date( '2009-04-29','yyyy-mm-dd')

;