Re: Time zone offset in to_char()

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Alban Hertroijs <a(dot)hertroijs(at)nieuwestroom(dot)nl>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Time zone offset in to_char()
Date: 2024-01-12 17:14:06
Message-ID: 2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/12/24 00:51, Alban Hertroijs wrote:

> Following up on my own mail from yesterday evening, here's the output
> that shows the function using set_config 'leaking' the timezone change
> to outside the function (the first select vs. the 2^nd  select) into the
> (same) transaction, whereas the function with the time zone bound to the
> header does not (the 3^rd  select).
> These are all from a single session, ran consecutively - a straight
> copy-paste from psql.

Alright I see what you are talking about.

>
> ciscache=> select ToDatetimeOffset(current_timestamp,
> 'Europe/Amsterdam'), to_char(current_timestamp, 'YYYY-MM-DD
> HH24:MI:SS.US0 TZH:TZM');
>           todatetimeoffset          |              to_char
> ------------------------------------+------------------------------------
>  2024-01-12 09:41:44.7019350 +01:00 | 2024-01-12 09:41:44.7019350 +01:00
> (1 row)
>
> ciscache=> select to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US0
> TZH:TZM');
>               to_char
> ------------------------------------
>  2024-01-12 08:41:54.4739800 +00:00
> (1 row)
>
> ciscache=> select ToDatetimeOffsetNL(current_timestamp),
> to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS.US0 TZH:TZM');
>          todatetimeoffsetnl         |              to_char
> ------------------------------------+------------------------------------
>  2024-01-12 09:42:44.1989210 +01:00 | 2024-01-12 08:42:44.1989210 +00:00
> (1 row)
>
> Regards,
> Alban Hertroijs.
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-01-12 17:18:38 Re: Issue with loading unicode characters with copy command
Previous Message David Hussey 2024-01-12 17:12:53 Support for arm64 windows is absent - Would be nice to have!