db2 luw 10.1 timestamp_format function

Koen Vannisselroy

db2 luw 10.1 timestamp_format function

Hello,

I try to convert a varchar to a timestamp using the timestamp_format function.

this is the query:

select timestamp_format(highvalue, 'YYYY-MM-DD-HH24.MI.SS.SSSSSS')

from syscat.datapartitions

;

highvalue in this syscat view is a varchar(512)

i get this error:

"'2017-03-31-23.59.59.999999'" cannot be interpreted using format string "YYYY-MM-DD-HH24.MI.SS" for the TIMESTAMP_FORMAT function.. SQLCODE=-20448, SQLSTATE=22007, DRIVER=4.18.60

Does anyone know how to write this query or how to convert from varchar to timestamp?

Olaf Stephan

RE: db2 luw 10.1 timestamp_format function
(in response to Koen Vannisselroy)

Hello,

 

please make sure that you select only valid date strings because range partitions can be also MINVALUE and MAXVALUE.

Check with : select distinct substr(HIGHVALUE,1,20) from syscat.datapartitions order by 1

Koen Vannisselroy

RE: db2 luw 10.1 timestamp_format function
(in response to Olaf Stephan)

thanks it works