Overview
Databrain allows you to pass a timezone parameter (params.timezone) while generating a guest token. This ensures that:
- SQL queries are executed in the correct timezone
- Date/time fields are consistently formatted
- Dashboard users across regions see accurate time-based insights
Supported Data Sources
Timezone-aware execution is supported for:- Clickhouse
- Trino
- Redshift
- CockroachDB
- Postgres
- MSSQL
What is params.timezone?
- Accepts a valid IANA timezone string
- Sets the database session timezone
- Ensures all date/time operations respect the specified timezone
Common Timezone Values
| Timezone | Description |
|---|---|
"UTC" | Coordinated Universal Time |
"America/New_York" | Eastern Time (US) |
"America/Los_Angeles" | Pacific Time (US) |
"Europe/London" | GMT / BST |
"Asia/Kolkata" | Indian Standard Time |
"Australia/Sydney" | Australian Eastern Time |
Guest Token Example with Timezone
Step-by-Step Implementation
Create a DataApp and API Token
Create the required resources via the following APIs:
Create a Datamart via API
Ensure your dataset contains a timestamp column. Create a Datamart using the Create Datamart API and specify isApplyTimezone.
Create an Embed via API
Create an Embed using your created datamart via the Create Embed API inside the created DataApp.
Generate Guest Token with Timezone
Include the Use an appropriate IANA timezone (e.g.,
params.timezone field in your payload when calling the Guest Token API."Asia/Kolkata").Validate in Demo Link
Open your demo link, click + Create Metric, and drag and drop the date column into the chart.Then:
- Open Browser DevTools → Network Tab
- Inspect the executed query
- The timezone value is applied in the query/session
"timezone": "<your-timezone>"is present inside the request payload (params)
How It Works Internally
The timezone is applied at the database session level. Queries run as if the database is operating in that timezone. Functions likeNOW(), DATE_TRUNC, and TIMESTAMP conversions will all respect the passed timezone.
