50

When I use DBeaver with Cassandra, it shows an offset of +01:00 even though the data is stored in Date or Times formats, that don't have any timezones. This results in some weird queries like this:

SELECT "Time"
FROM keyspace."Table"
ORDER BY "Time" DESC;

Time
00:00:00
23:00:00
22:00:00
...
01:00:00

So, how do I remove the conversions or do I set the timezone to UTC?

Edu
  • 2,354
  • 5
  • 32
  • 36

9 Answers9

50

v22.1.0 added this preference in the UI (no more modifying .ini files).

In Window -> Preferences. Go to User Interface and change the Client Timezone. Restart dbeaver.

Github PR here: https://github.com/dbeaver/dbeaver/pull/16467

enter image description here

Gabe
  • 5,113
  • 11
  • 55
  • 88
45

I found another solution:

Setting dbeaver.ini file in DBeaver root directory.

Open the file:

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.551.v20171108-1834
-showsplash
# START: change jre version, not using the one in %JAVA_HOME%
-vm 
D:\ArPortable\Java\jdk1.8.0_171\jre\bin\server\jvm.dll
# END
# JVM settings
-vmargs
-XX:+IgnoreUnrecognizedVMOptions
--add-modules=ALL-SYSTEM
-Xms64m
-Xmx1024m
# time zone
-Duser.timezone=UTC
# language
-Duser.language=en
Archon
  • 1,385
  • 1
  • 15
  • 30
  • This doesn't work if the server timezone isn't UTC, or if you use multiple servers with different timezones. [See this answer](https://stackoverflow.com/a/54401047/8213783) – Evan Jun 17 '19 at 21:21
  • This fixed the "ERROR: invalid value for parameter "TimeZone": "Europe/Berlin"" for me with using CockroachDB on Windows 10. – Ferdy Pruis Jan 29 '20 at 09:33
  • See my answer below - there is a much easier option in settings UI starting in v22.1. https://stackoverflow.com/a/72533665/220997 – Gabe Aug 12 '22 at 14:09
23

DBeaver uses the time in the computer that is installed, so changing the clock and restarting DBeaver works. But there is a way to do it only for DBeaver instead.

  • Close DBeaver.
  • Go to the DBeaver shortcut. Probably it is here:

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\DBeaver

  • Right-click on it, choose Properties and in the Target box add -vmargs -Duser.timezone=UTC to the end, resulting in something like this:

    "C:\Program Files\DBeaver\dbeaver.exe" -vmargs -Duser.timezone=UTC

  • Start DBeaver and the times now appear in UTC.

Edu
  • 2,354
  • 5
  • 32
  • 36
  • 3
    Providing those parameters to the program didn't work for me, but I was able to just modify **dbeaver.ini** and add the `vmarg` there. Then it worked. – Shibumi Apr 13 '18 at 15:22
  • 5
    I had to add `-Duser.timezone=UTC` on the line just below `-vmargs` in __dbeaver.ini__, and restart the app. Putting it on the same line did not work. And this was inside the app package on MacOS, so it's bound to be overwritten during the next app update. – John Lemberger Jun 28 '18 at 18:44
  • @JohnLemberger That putting a configuration option on the same line as `-vmargs` doesn't work is expected: since DBeaver is Eclipse-based, [Eclipse.ini](https://wiki.eclipse.org/Eclipse.ini) settings and rules apply. – watery Jan 23 '19 at 16:21
  • can you give an example for setting Europe/Berlin timezone in dbeaver.ini? I tried -vmargs -Duser.timezone=Europe/Berlin – Leevi L Apr 08 '20 at 10:41
  • 1
    @LeeviL I would not advise using anything other than UTC for the reasons stated in the question. But for your case, if Europe/Berlin does not work, try CET, or +01:00 or related. – Edu Apr 08 '20 at 21:26
  • It's kind of crazy that there's no way to tell DBeaver to use the server's time zone in a way that persists across updates. – Alex Totheroh Jun 04 '20 at 20:05
14

On Mac

  1. Go to Finder > Applications
  2. Right click on DBeaver and select Show Package Contents
  3. Open Contents\Eclipse\dbeaver.ini
  4. After the -vmargs line, add this: -Duser.timezone=UTC
  5. Save file and restart DBeaver

Limitation: You’ll have to redo this for every version upgrade.

Windows

  1. Go to DBeaver install directory C:\Program Files\DBeaver
  2. Open dbeaver.ini
  3. After the -vmargs line, add this: -Duser.timezone=UTC
  4. Save file and restart DBeaver

Source: This blog

arcseldon
  • 35,523
  • 17
  • 121
  • 125
13

UPDATE 2021-04-05: Based on recent comments I need to clear that this solution suitable only for Clickhouse DB. Additionally it is very old answer, please, take in mind that it is currently 99% outdated solution.

I think it was fixed in some previous release.

Just go to Settings -> Editors -> Data Formats and select 'Use native date/time format' checkbox.

enter image description here

valentinmk
  • 597
  • 7
  • 18
  • 4
    This doesn't work for me, dates and times are still converted to local time – Wes Feb 13 '19 at 16:00
  • @Wes I have double checked solution and it works for me. But this works for a DBeaver 5.3.2 and Clickhouse database for a fields with DateTime type – valentinmk Feb 15 '19 at 14:11
  • If it helps, I am working in Postgres and running `to_timestamp()` on an epoch timestamp. The solutions above worked for me though. – Wes Feb 17 '19 at 16:04
  • 11
    No, this does **_not work_**. It only affects the **_format_** of timestamps (i.e., "YYYY-MM-DD" vs. "MM-DD-YYYY", etc.), not the **_value_** displayed (i.e., UTC vs. your local time zone). – Mr. Lance E Sloan Mar 26 '20 at 14:32
7

If you wanna see the TimeZone of your Selects, you can go to DBeaver Preferences:

Preferences enter image description here

  1. Click on Type, and change it to Timestamp
  2. In Pattern Value add the termination " Z z" and see the Sample result like this: 2019-11-06 07:38:54 -0300 BRT
  3. Tap Apply, and Apply and Close
  4. Done :)
6

For DBeaver in Linux

  1. Quit DBeaver if it's running.

  2. Edit /usr/share/dbeaver/dbeaver.ini, adding -Duser.timezone=UTC to -vmargs section. E.g.:

     -vmargs
     -XX:+IgnoreUnrecognizedVMOptions
     --add-modules=ALL-SYSTEM
     -Dosgi.requiredJavaVersion=11
     -Xms64m
     -Xmx1024m
     -Duser.timezone=UTC
    
  3. Open DBeaver and view timestamps in UTC.

Viewing full timestamp values

  1. Window > Preferences
  2. Editors > Data Editor > Data Formats
  3. Check 'Disable date/time formatting'

Before: 2021-04-19 16:14:23

After: 2021-04-19 16:14:23.056178+00

Tested with PostgreSQL.

David Oliver
  • 2,424
  • 1
  • 24
  • 37
4

If this is the JDBC driver issue with regards to the timezone:
Right click on the connection to open connection settings

right click on the connection to open connection settings

change the timezone change the timezone for the connection

OR you may also change the server timezone driver property OR you may change the server timezone driver property

4

As of today (DBeaver 21.3.2 CE) you need to go to Window > Preferences. In the dialog pop-up window choose: Editors > Data Editor > Formats, then choose Timestamp in the dropdown in the Format frame and click on Timesone line.

enter image description here

Right-click there and print UTC

enter image description here

Click the 'Apply and Close' button in the lower right corner. Done!

Alex Fedotov
  • 497
  • 3
  • 8