generate_series for timestamptz and time zone problem

From: Przemysław Sztoch <przemyslaw(at)sztoch(dot)pl>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: generate_series for timestamptz and time zone problem
Date: 2022-05-31 19:54:05
Message-ID: 01a84551-48dd-1359-bf7e-f6b0203a6bd0@sztoch.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

|generate_series| ( /|start|/ |timestamp with time zone|, /|stop|/
|timestamp with time zone|, /|step|/ |interval| )
produces results depending on the timezone value set:

SET timezone = 'UTC';
SELECT ts, ts AT TIME ZONE 'UTC'
FROM generate_series('2022-03-26 00:00:00+01'::timestamptz, '2022-03-30
00:00:00+01'::timestamptz, '1 day') AS ts;

SET timezone = 'Europe/Warsaw';
SELECT ts, ts AT TIME ZONE 'UTC'
FROM generate_series('2022-03-26 00:00:00+01'::timestamptz, '2022-03-30
00:00:00+01'::timestamptz, '1 day') AS ts;

Sometimes this is a very big problem.

The fourth argument with the time zone will be very useful:
|generate_series| ( /|start|/ |timestamp with time zone|, /|stop|/
|timestamp with time zone|, /|step|/ |interval|  [, zone text] )

The situation is similar with the function timestamptz_pl_interval. The
third parameter for specifying the zone would be very useful.

--
Przemysław Sztoch | Mobile +48 509 99 00 66

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-05-31 19:57:14 Re: pg15b1: FailedAssertion("val > base", File: "...src/include/utils/relptr.h", Line: 67, PID: 30485)
Previous Message Tom Lane 2022-05-31 19:49:09 Re: Prevent writes on large objects in read-only transactions