The Timestamp is the localtime of the DB2 Server. The date was stored in the time zone Europe / Berlin.
I would like to convert the then stored date to UTC. Is there a way to calculate this in DB2 Dialect?
The Timestamp is the localtime of the DB2 Server. The date was stored in the time zone Europe / Berlin.
I would like to convert the then stored date to UTC. Is there a way to calculate this in DB2 Dialect?
Your best bet is to use the TIMEZONE function and to use CURRENT TIMEZONE as help for the input.
The function converts date and time from one to another timezone. The register CURRENT TIMEZONE gives you the difference between server timezone and UTC.
Check out the TO_UTC_TIMESTAMP scalar function
values TO_UTC_TIMESTAMP(TIMESTAMP'2019-10-01 00:00:00', 'Europe/Berlin')
Please note the second parameter is case sensitive. There is also a FROM_UTC_TIMESTAMP if needed.
As @data_henrik pointed out, CURRENT TIMEZONE is the special register to use, it can be simply subtracted from CURRENT TIMESTAMP e.g.:
db2 "values CURRENT TIMESTAMP - CURRENT TIMEZONE"
1
--------------------------
2019-10-16-11.36.24.025651
1 record(s) selected.