Assuming in your DB2 database there's sample.table with a column containing t_time and named the same. A conversion from time_t to a DB2 timestamp could be done like this:
SELECTThe result would look like the following:
DISTINCT time_t,
timestamp('1970-01-01-00.00.00') + (time_t) seconds
as calculated_timestamp
FROM
sample.table
WHERE
time_t=946684800
;
TIME_T CALCULATED_TIMESTAMP
----------- --------------------------
946684800 2000-01-01-00.00.00.000000
1 record(s) selected.
This is also useful for changing the time value permanently from time_t to timestamp when working with DB2 on Unix log data. Daily logs containing time_t could be loaded into a temporary table in the first step. When adding the data to the permament table (working with a timestamp column) , a load is to be done from a cursor which has to be defined as SELECT using the above mentioned conversion.
Keine Kommentare:
Kommentar veröffentlichen