Setting the correct timezone for your Snowflake account, user, and sessions is an often overlooked aspect of building with Snowflake. This post will guide you through why it's important, how to check and adjust your time settings, and key best practices for managing timezones in Snowflake.
Why is Your Snowflake's Account, User, and Session Timezone Important?
Understanding the role of timezone settings in Snowflake is crucial for accurate data analysis and interpretation. There are three timezone settings you'll encounter in Snowflake - the account, the user, and the session timezone.
The account timezone, which is set at the instance level, serves as the default for all sessions and influences various operations, such as timestamp generation. On the other hand, the user and session timezone applies to a single user or session and impacts the interpretation of timestamp data within that session. A session timezone, if set, will override the account timezone.
How to Check What Timezone the Snowflake Account and Session Are On
To check the timezone of your Snowflake account or session, use the following queries:
The first command shows the account's timezone, while the second returns the current timestamp for the session, where you can see on what timezone it is.
Best Practices for Setting Timezones: Keep Everything in UTC
When it comes to setting timezones in Snowflake, our recommended best practice is to keep everything in Coordinated Universal Time (UTC). Using UTC as your standard can simplify data analysis and comparisons, as it eliminates the issues caused by daylight saving time changes and regional differences.
How to Change the Session or User's Timezone
To change the timezone for your session in Snowflake, use the <span class="code-exp">ALTER SESSION</span> or <span class="code-exp">ALTER USER</span> command:
This command sets the session or user timezone to UTC. You can replace 'UTC' with any valid timezone identifier, according to your needs.
You can specify a time zone name or a link name from release 2021a of the IANA Time Zone Database (e.g. <span class="code-exp">America/Los_Angeles</span>, <span class="code-exp">Europe/London</span>, <span class="code-exp">UTC</span>, <span class="code-exp">Etc/GMT</span>, etc.).
How to Change the Account's Timezone
To change the account timezone, you'll need to have the ACCOUNTADMIN role. The command to modify the account timezone is as follows:
Remember that changing the account timezone will impact all sessions unless they have a different session timezone set.
Source: Snowflake Documentation
Setting up timezones correctly in your Snowflake account and sessions is crucial for accurate data interpretation. By following these steps and best practices, you can ensure precise time handling for your Snowflake operations.
If you are interested in diving deeper into Snowflake capabilities, here are some blog posts you might find useful:
- Snowflake API: Comprehensive Guide to 3 Methods With Examples
- How to reduce Snowflake costs: A five-point checklist
- How to build in-product analytics with Snowflake and GraphQL
If you don’t have a Propel account yet, you can try Propel for free and start building data apps.