KNOWLEDGE BASE

Timestamp with Time Zone Converted to UTC in PostgreSQL


Published: 24 Jan 2017
Last Modified Date: 27 Feb 2017

Issue

When connecting to a Postgres database that contains a TIMESTAMPTZ column (Timestamp with Time Zone), all query results are returned in UTC, regardless of your location and local time zone. Issuing queries from another application on the same computer returns times converted to the local time zone.

Environment

  • Tableau Desktop
  • PostgreSQL

Resolution

Use a pass-through function like the one below:

RAWSQL_DATETIME("%1 AT TIME ZONE 'PST8PDT'", [TIMESTAMPTZ Field])

You can also create a parameter for the time zone and allow users to select their local time zone, using something like the following:

RAWSQL_DATETIME("%1 AT TIME ZONE %2", [TIMESTAMPTZ Field], [Time Zone Parameter) 

Cause

Tableau connections to PostgreSQL prevent the database server from converting timestamps to the client local time zone, since this conversion can lead to inconsistent visualizations for users collaborating from different regions, especially when date/time filters are involved. 
Did this article resolve the issue?