KNOWLEDGE BASE

Custom timezone set using Initial SQL is not respected by the PostgreSQL JDBC driver


Published: 04 Mar 2022
Last Modified Date: 04 Mar 2022

Issue

In versions of Tableau that use the PostgreSQL JDBC driver (2020.4 and above), if you set a custom timezone using initial SQL (e.g. set timezone to 'cet'), the timezone is not respected by the now() function when it is used in custom SQL to connect to your data. Values returned by the now() function are always in the UTC timezone.
 

Environment

Tableau Desktop, Tableau Server, Tableau Prep Builder, Tableau Online. 2020.4 and above.
 

Resolution

Upgrade to Tableau Desktop/Server 2021.2.1, 2021.1.4, 2020.4.7 or later.

Or,

In Tableau versions 2020.4.7, 2021.1.4, 2021.2.1, and above, use the localtimestamp function in your custom SQL instead of the now() function
 

Cause

This is a known issue that is fixed in more recent version Tableau Desktop and Tableau Server.

Additional Information

"The NOW() function in Tableau calculated fields also behaves differently between the PostgreSQL ODBC and JDBC driver, irrespective of whether a custom timezone is set using initial SQL.

ODBC (2020.3 and prior): The NOW() function returns local system time
JDBC (2020.4 and above): The NOW() function returns current UTC time
 
Did this article resolve the issue?