Skip to Content

Solution Patterns

Set the viewer's timezone

Run each viewer's queries in their own timezone with params.timezone in the guest token.

Send an IANA timezone name in params.timezone. Databrain uses it when it runs that viewer’s queries.

Steps

  1. In your backend, get the viewer’s timezone, for example America/New_York.
  2. Add it to the guest token:
{
  "clientId": "acme-corp",
  "dataAppName": "Customer Analytics",
  "params": {
    "timezone": "America/New_York"
  }
}
  1. To convert a date column in filters, open the datamart and turn on Apply timezone for that column. It applies to date and time columns only.

Queries for this viewer now run in America/New_York.

Valid values

Use a name from the IANA time zone database, for example UTC, Asia/Kolkata or Europe/Berlin. Databrain removes spaces at the start and end. A blank value or a name the server does not know is refused.

Where it applies

Databrain sets the session timezone before each query on these datasources:

Session timezone setSession timezone not set
PostgreSQL, CockroachDB, Snowflake, MySQL, Athena, Databricks, Amazon S3, CSVBigQuery, ClickHouse, Microsoft SQL Server, Microsoft Fabric, Trino, SingleStore, Firebolt, MongoDB, OpenSearch, Elasticsearch

On every datasource, date filters on a column with Apply timezone turned on convert that column to the token’s timezone.

If something goes wrong

  • 400 INVALID_REQUEST_BODY: “Invalid timezone”. The server does not know the name, or it is only spaces. Use an IANA name such as Asia/Kolkata.
  • 400 INVALID_REQUEST_BODY: "params.timezone" is not allowed to be empty. Leave the field out instead of sending "".

Related: Fiscal year calendar.