2

I am wondering why I am getting different times from this post Post

set timezone to 'UTC';

SELECT timestamptz '2012-03-05 17:00:00+0';  
Expected :2012-03-05 17:00:00+00
Got : 2012-03-05 22:30:00

SET timezone TO 'Europe/Berlin';

SELECT '2012-03-05 17:00:00+0'::timestamptz;  
Expected :  2012-03-05 18:00:00+01
Got: 2012-03-05 22:30:00



SELECT timestamptz '2012-03-05 18:00:00+1';
Expected : 2012-03-05 17:00:00+00
Got : 2012-03-05 22:30:00
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Prabhat Mishra
  • 951
  • 2
  • 12
  • 33

3 Answers3

1

Actually I am using DBeaver as a DB IDE and there we need to do some adjustments in dbeaver.ini refer this post for more insight

Prabhat Mishra
  • 951
  • 2
  • 12
  • 33
0

I believe the issue is how you are setting your timezone.

Can you try changing SET timezone TO to SET TIME ZONE and see if it works?

You can see the documentation below for more help: https://www.postgresql.org/docs/9.1/datatype-datetime.html#DATATYPE-TIMEZONES

Japes
  • 56
  • 5
0

Your expectations are correct. The problem must be that you are running the statements in different database sessions.

The scope of SET is limited to the current session.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263