Skip to content

How to set the time zone at the user level

4 minute read
Content level: Intermediate
0

Amazon Redshift defaults to UTC for all sessions. Common workarounds like SET timezone or CONVERT_TIMEZONE are session-scoped or query-scoped, making them easy to forget and leading to inconsistent results. This article shows how to use ALTER USER to persistently set the time zone at the user level — for both local and SSO/federated users — so the correct time zone is applied automatically on every login.

Amazon Redshift uses UTC (Coordinated Universal Time) as the default time zone. When using functions such as GETDATE() or SYSDATE, the results are returned in UTC. However, many users need their local time zone applied consistently for ETL processes, reports, and ad-hoc queries. Common approaches like SET timezone only apply to the current session and are lost on disconnect. The CONVERT_TIMEZONE function requires explicit use in every query. Both are easy to forget, leading to inconsistent results. The ALTER USER command provides a persistent solution — once set, the desired time zone is automatically applied every time the user logs in. This must be configured per user (for local users) or per IAM role (for federated access or AWS Identity Center users). Important: You cannot set the timezone at cluster level through a parameter group. The Redshift documentation states: "You can't set the timezone configuration parameter by using a cluster parameter group." The only persistent option is at the user level. Amazon Redshift uses the IANA Time Zone Database as the authoritative source of time zone specification.

Setting timezone for local users Local users must be altered individually. In this example, we set the timezone for user "ricardo" to Japan.

Step 1 — As the administrator, alter the user “ricardo" to set the new timezone: Enter image description here

Step 2 — Now check the current timezone for the administrator user: Enter image description here

Note: The change does not affect the administrator's current session. It takes effect the next time "ricardo" logs in.

Step 3 — Log in as "ricardo" and verify: The time zone persists across all future sessions for this user. Enter image description here

Reset to default — To revert the user back to UTC (it will be applied to all future sessions for the user):

Enter image description here

Note that you have to logoff to be able to reset the time zone. Enter image description here

Setting timezone for SSO / Federated users When using IAM roles to log in (federated access) or AWS Identity Center (IDC), Redshift creates a database user prefixed with IAMR: followed by the role name. You need to alter that mapped user.

Step 1 — Identify the IAM role being used. Log in as the SSO user and run: Enter image description here

Let's also check the current time zone Enter image description here

Step 2 — As the administrator, check the current timezone: Now, let’s use the administrator user to set the time zone for the IAM role Logged as administrator Enter image description here

See that we have UTC here as well Enter image description here

Step 3 — Alter the federated user. Note the IAMR: prefix and double quotes: Enter image description here

Step 4 — Log out and log back in as the SSO user to verify: Enter image description here

After logging back in, we can see the new timezone. Enter image description here

In summary, ALTER USER ... SET timezone is a persistent way to change the timezone in Amazon Redshift — it applies automatically on every login, works for both local and SSO/federated users, and requires no changes to your queries or ETL processes.

AWS
EXPERT
published 2 months ago76 views