当日期格式为DD-MM-YY HH24:MI:SS.000 上午 这种格式的时候转成date类型的方法
使用最笨的方法进行截取字符串
select (case when 时间 is null then '9999'
else '20'||substr(时间,instr(时间,'-',-1,1)+1,2) end )|| --年
(case when 时间 is null then '12'
when substr(substr(时间 ,instr(时间 ,'-',1)+1,2),2) = '月'
then '0'||substr(时间 ,instr(时间 ,'-',1)+1,1)
else substr(时间 ,instr(时间 ,'-',1)+1,2)end)|| --月
(case when 时间 is null then '31'
else substr(时间,1,2) end )|| --日
(case when 时间 is null then '121212'
else replace(substr(时间,instr(时间,'-',-1,1)+4,8),'.','') end) --时分秒
from 表
这样子格式就是正常的了然后在进行to_date转换就可以了
博客介绍了将日期格式为DD-MM-YY HH24:MI:SS.000 上午的数据转换为date类型的方法,即先使用截取字符串的方式使格式正常,再进行to_date转换。

5万+

被折叠的 条评论
为什么被折叠?



