From: Adrian Klaver
> I didn’t succeed in calling SET LOCAL TIMEZONE from within the function.
> Could be I missed something, then Google (stackoverflow) pointed me to
> set_config().
CREATE OR REPLACE FUNCTION public.tz_fnc()
RETURNS void
LANGUAGE plpgsql
AS $function$
BEGIN
SET LOCA
iscache=> select ToDatetimeOffsetNL(current_timestamp),
to_char(current_timestamp, '-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.
> In the above, I worked around the issue using a couple of user-defined
> functions in PG. That should give a reasonable idea of the desired
> functionality, but it's not an ideal solution to my problem:
> 1). The first function has as a drawback that it changes the time zone for
> the entire t
Am 11.01.2024 um 16:06 schrieb Alban Hertroijs :
Hi all,
I'm basically looking for a one-liner to convert a timestamptz (or a timestamp
w/o time zone if that turns out to be more convenient) to a string format equal
to what MS uses for their datetimeoffset type. I got almost there
if not, at least without having
to hard-code the time zone or leaking the time zone change to other calls
within the same transaction?
Any suggestions much appreciated.
Groet,
Alban Hertroijs
Data engineer ∙ NieuweStroom
aanwezig ma t/m vr, di tot 13:30 uur
[Afbeelding met tek