Reputation: 415
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?
Upvotes: 2
Views: 3305
Reputation: 4005
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.
Upvotes: 1
Reputation: 17118
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.
Upvotes: 1
Reputation: 601
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.
Upvotes: 1