17,086
社区成员
发帖
与我相关
我的任务
分享
--转换为timestam类型可直接与date比较
to_timestamp('2010-04-26-11.28.22.878197','yyyy-mm-dd-hh24.mi.ss.ff')
--也可进一步转换timestamp到date类型
cast(to_timestamp('2010-04-26-11.28.22.878197','yyyy-mm-dd-hh24.mi.ss.ff') as date)
--最笨的方法,截取字符串,连接后转换为日期
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
SQL> with t as(
2 select to_date(substr('2010-04-26-11.28.22.878197',1,10)||' '||
3 substr('2010-04-26-11.28.22.878197',12,8)
4 ,'yyyy-mm-dd hh24:mi:ss') dt
5 from dual)
6 select dt,dt+1,dt+10 from t
7 /
DT DT+1 DT+10
------------------- ------------------- -------------------
2010-04-26 11:28:22 2010-04-27 11:28:22 2010-05-06 11:28:22