sqldatabasepostgresqltimezonetimestamp-with-timezone

PostgreSQL `at timezone` unexpected behaviour


When running the following queries, the expected result would be the same (2023-01-16 16:39:24.824000) as the current timezone in Europe/Tirana is CEST. However, the results I receive are as shown:

select '2023-01-16 14:39:24.824000 +00:00' at time zone 'Europe/Tirane';
select '2023-01-16 14:39:24.824000 +00:00' at time zone 'CEST';
2023-01-16 15:39:24.824000
2023-01-16 16:39:24.824000

Meaning that Europe/Tirana does not return the correct result. Am I missing something? Why is this behaviour happening? Thank you in advance!

I tried using ::timestamptz and some other suggestions I found but the result remained unchanged.


Solution

  • The result is correct because the Europe/Tirane time zone was switched from CET (UTC+1) to CEST (UTC+2) on 2023-03-26.

    2023    dim 26 mar, 02 h 00 CET → CEST  +1 hour (DST start) UTC+2h
            dim 29 oct, 03 h 00 CEST → CET  -1 hour (DST end)   UTC+1h
    

    so the result of : select '2023-01-16 14:39:24.824000 +00:00' at time zone 'Europe/Tirane';

    should be 2023-01-16 15:39:24.824 , because 2023-01-16 is before 2023-03-26