pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Alban Hertroys <haramrae@gmail.com>
Cc: Alban Hertroys <a.hertroijs@nieuwestroom.nl>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Time zone offset in to_char()
Date: Thu, 11 Jan 2024 13:15:44 -0800
Message-ID: <e0166046-fabf-49c4-a754-b0868e003563@aklaver.com> (raw)
In-Reply-To: <752055E6-31DA-404F-AB5E-0BAB83836108@gmail.com>
References: <DB8P189MB1046C0D82500690791CED07AE2682@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM>
	<11b56239-9f18-4b94-aeac-395648a2bfe3@aklaver.com>
	<752055E6-31DA-404F-AB5E-0BAB83836108@gmail.com>

On 1/11/24 11:04, Alban Hertroys wrote:
> 

> I did manage to apply it to the second function header, which I think behaves such that the time zone change stays within function scope. Right now I’m not 100% sure that I verified that. More to check tomorrow.


CREATE OR REPLACE FUNCTION public.tz_fnc2()
  RETURNS void
  LANGUAGE plpgsql
  SET "TimeZone" TO 'UTC'
AS $function$
BEGIN
     RAISE NOTICE '%', to_char(now(), 'OF');
END;
$function$;


test=# begin ;
BEGIN
test=*# select public.tz_fnc2();
NOTICE:  +00
  tz_fnc2
---------

(1 row)

test=*# show timezone;
  TimeZone
----------
  UTC
(1 row)

test=*# commit ;
COMMIT
test=# show timezone;
  TimeZone
----------
  UTC
(1 row)


> 
> Frankly, I do hope that you’re right here, that would make my work easier.
> 
> Alban Hertroys
> --
> If you can't see the forest for the trees,
> cut the trees and you'll find there is no forest.
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (21+ messages)  latest in thread

Message-ID: <e0166046-fabf-49c4-a754-b0868e003563@aklaver.com>
Permalink:  ../e0166046-fabf-49c4-a754-b0868e003563@aklaver.com/
Also on:    postgresql.org/message-id/e0166046-fabf-49c4-a754-b0868e003563@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, haramrae@gmail.com, a.hertroijs@nieuwestroom.nl
  Subject: Re: Time zone offset in to_char()
  In-Reply-To: <e0166046-fabf-49c4-a754-b0868e003563@aklaver.com>
  References: <DB8P189MB1046C0D82500690791CED07AE2682@DB8P189MB1046.EURP189.PROD.OUTLOOK.COM> <11b56239-9f18-4b94-aeac-395648a2bfe3@aklaver.com> <752055E6-31DA-404F-AB5E-0BAB83836108@gmail.com> <e0166046-fabf-49c4-a754-b0868e003563@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