我有一个字段是varchar2类型的。存的是时间格式20150917140932。我想转换成2015-09-17在where条件中检索出来为什么不行呢?检索没数据
select id,to_char(to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss'),'yyyy-mm-dd'),type, ids, parameters
from tttt
where to_char(to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss'),'yyyy-mm-dd')> '2015-09-17'
------解决思路----------------------
select id,to_char(to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss'),'yyyy-MM-dd'),type, ids, parameters
from tttt
where to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss')>to_date( '2015-09-17','yyyy-MM-dd')
试试
------解决思路----------------------
试试这样可不可以
select id,to_char(to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss'),'yyyy-mm-dd'),type, ids, parameters
from tttt
WHERE to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss')> to_date('2015-09-17','yyyy-mm-dd hh24:mi:ss')
------解决思路----------------------
select to_char(to_date('20150917140932', 'yyyy-MM-dd hh24:mi:ss'),'yyyy-mm-dd') from dual
返回的结果就是2015-09-17
如果where中是>,应该没结果的,要>=吧。
------解决思路----------------------
to_char(to_date(date_validated, 'yyyy-MM-dd hh24:mi:ss'),'yyyy-mm-dd')> '2015-09-17'
如果date_validated为20150917140932的话,两边就相等了