2

我在 BD2 表中有一个 varchar 值,如下格式

121226145503+0530

我想将此 varchar 值转换为时间戳格式,如下所示

2012/12/26 14:55:03
4

2 回答 2

1

在 DB2 9.7 中,您还可以使用 TO_DATE 函数:

date(to_date(column_with_date,'DD-MM-YYYY HH:MI:SS'))

此外,您可以使用该TRANSLATE功能

select 
   date(translate('DD/MM/YYYY',column-with-the-date,'xyz...'))
from
   table
于 2013-01-23T08:17:31.623 回答
0
with d (cwd) as                                              
 (values( cast( '121226145503+0530' as varchar(20))))        
select cwd as vc_input                                       
 ,  to_date(cwd, 'YYMMDDHH24MISS'      )        as ts_from_vc
 ,  varchar_format  ( to_date(cwd, 'YYMMDDHH24MISS')         
                    , 'YYYY/MM/DD HH24:MI:SS' ) as vc_from_ts
from d                                                       
; -- output from above query follows, as likeness of a report:
....+....1....+....2....+....3....+....4....+....5....+....6....+....
VC_INPUT              TS_FROM_VC                  VC_FROM_TS         
121226145503+0530     2012-12-26-14.55.03.000000  2012/12/26 14:55:03
********  End of data  ********                                      
于 2016-08-15T01:41:06.150 回答