【发布时间】:2014-08-20 16:26:34
【问题描述】:
有一个表的日期列类型为 varchar2。该字段值的格式为:2013-12-19T12:12:23.345000000Z 我必须找出两个连续日期之间的差异。但由于日期是字符串格式,我首先将其转换为时间戳。我使用以下查询。
select dccontextid,
to_timestamp(substr(cdate,1,10)||' '||substr(cdate,12,12),'yyyy-mm-dd hh24:mi:ss.ff')
from cam6eng.ttestcolorproc_wd
where to_timestamp(substr(cdate,1,10)||' '||substr(cdate,12,12),'yyyy-mm-dd hh24:mi:ss.ff') between :StartDate and :EndDate
如果上面的查询在没有包含 where 子句的情况下运行,它会显示正确的时间戳值。但是当我输入 where 子句时,它给出了错误 ORA-01852 Seconds must be between 0 and 59. (这是因为有些记录有 second=59 和 fraction=一些非零值)
有什么办法可以解决这个问题?
【问题讨论】: