How can I get the current session timezone in Redshift?

Viewed 1826

I know that I can the session timezone with

SET TIMEZONE TO 'CET';

But is there a way to get it back? I want something like

SELECT SESSIONTIMEZONE, SYSDATE, SYSDATE::timestamptz, SYSDATE::timestamptz AT TIME ZONE 'UTC', SYSDATE::timestamptz AT TIME ZONE 'CET'; 

which I would expect to return

UTC| ... 12:23:55.963747 | ... 12:23:55.963747+00 | ... 12:23:55.963747+00 | ... 12:23:55.963747+01

Is there a way to get it? I don't see any functio CURRENT_TIMEZONE or GET_TIMEZONE.

1 Answers

You can use CURRENT_SETTING('timezone') to get it or SHOW TIMEZONE;

select current_setting('timezone'), sysdate, sysdate::timestamptz, sysdate::timestamptz at time zone 'utc', sysdate::timestamptz at time zone 'cet';
UTC 2021-03-19 12:48:09.989592  2021-03-19 12:48:09.989592+00   2021-03-19 12:48:09.989592  2021-03-19 13:48:09.989592
Related