pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Alban Hertroijs <a.hertroijs@nieuwestroom.nl>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Time zone offset in to_char()
Date: Fri, 12 Jan 2024 09:14:06 -0800
Message-ID: <2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com> (raw)
In-Reply-To: <DB8P189MB1046B4714D58CA7262A31CE1E26F2@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM>
References: <DB8P189MB1046C0D82500690791CED07AE2682@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM>
	<11b56239-9f18-4b94-aeac-395648a2bfe3@aklaver.com>
	<752055E6-31DA-404F-AB5E-0BAB83836108@gmail.com>
	<DB8P189MB1046B4714D58CA7262A31CE1E26F2@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM>

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.klaver@aklaver.com






view thread (21+ messages)  latest in thread

Message-ID: <2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com>
Permalink:  ../2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com/
Also on:    postgresql.org/message-id/2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, a.hertroijs@nieuwestroom.nl
  Subject: Re: Time zone offset in to_char()
  In-Reply-To: <2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com>
  References: <DB8P189MB1046C0D82500690791CED07AE2682@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM> <11b56239-9f18-4b94-aeac-395648a2bfe3@aklaver.com> <752055E6-31DA-404F-AB5E-0BAB83836108@gmail.com> <DB8P189MB1046B4714D58CA7262A31CE1E26F2@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM> <2804e2d7-3c27-4097-97d9-d05377dbb31b@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox