DataGrip date-time display and session time zone synchronization
0 reputation · 01 Sept 2024, 16:02 UTC
0 reputation · 01 Sept 2024, 16:02 UTC
DataGrip manages the representation of TIMESTAMP and DATETIME types through a combination of global IDE preferences and specific Data Source properties. While the IDE allows users to toggle between system local time and UTC, the interaction between these settings and the database server's own session offset can create discrepancies in the result grid.
The goal is to ensure that date-time values are displayed according to the server's regional settings without the IDE's internal time zone preference overriding the returned offset. This is particularly relevant when using custom 'Data Formats' patterns to standardize display across different regional database instances.
Which configuration priority ensures the database server's session offset takes precedence over the IDE's global time zone setting?
Are there specific driver-level parameters required to prevent the IDE from automatically converting these values in the Value Editor panel?
34775 reputation · 01 Sept 2024, 17:21 UTC
There is no single "priority" toggle in DataGrip. Display is resolved in layers, and the per-data-source setting always beats the global IDE setting. To make the server's session offset take precedence, you set the per-data-source Time zone (Data Source Properties → Options → Time zone) to the server's zone — or to a fixed zone such as UTC — and you set the matching JDBC driver parameter in the connection URL so the server actually returns values in that zone. The global IDE preference (Settings → Tools → Database → Data Views → Time zone) only applies when the data source is left on "Default".
So "server offset takes precedence" is really achieved by aligning layer 1 with layer 3: pick the display zone explicitly at the data-source level, and make the driver negotiate the same zone with the server.
Yes — these are required if you want the server session to stop applying its own default. Common examples (verify against your driver version, since defaults have changed across releases):
serverTimezone=UTC (alias connectionTimeZone) plus forceConnectionTimeZoneToSession=true to push it into the server session.timezone connection parameter sets the client zone; the session otherwise follows the server's TimeZone setting.oracle.jdbc.timezoneAsRegion and the JVM user.timezone fallback.Add these to the URL under Data Source Properties → General, e.g. jdbc:mysql://host/db?serverTimezone=UTC&forceConnectionTimeZoneToSession=true.
There is no driver-level "do not convert" switch for the Value Editor. It formats using the same active display zone (per-data-source → global). One important distinction:
Note that custom Data Formats patterns only change rendering after zone interpretation; they never affect conversion.
SELECT @@session.time_zone (MySQL), SHOW TIME ZONE (PostgreSQL), or SELECT SESSIONTIMEZONE FROM DUAL (Oracle).If timestamps still shift unexpectedly, the missing diagnostic is the exact column type (TIMESTAMP vs TIMESTAMPTZ) and the JDBC driver version — both change which layer is doing the conversion, so confirm those before changing more settings.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.