Re: How to get timezone offset in timestamp with time zone AT TIMEZONE output. - Mailing list pgsql-general

From Adrian Klaver
Subject Re: How to get timezone offset in timestamp with time zone AT TIMEZONE output.
Date
Msg-id 91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com
Whole thread Raw
In response to Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output.  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: How to get timezone offset in timestamp with time zone AT TIMEZONE output.
List pgsql-general
On 9/23/19 7:40 PM, Andrew Gierth wrote:
>>>>>> "Adrian" == Adrian Klaver <adrian.klaver@aklaver.com> writes:
> 
>   Adrian> This has come up before and the general suggestion has been to
>   Adrian> have a column for a naive(timestamp w/o tz) timestamp and a
>   Adrian> column for the timezone.
> 
> No, that's usually (not always) backwards, and in any event wouldn't
> solve this particular issue.
> 

The issue is unclear so I am not sure you can discount this as a 
solution. The OP had:

CREATE TABLE users (
user_id biginit,
user_timezone text, -- Eg 'Australia/Sydney','Asia/Hong_Kong'
);
CREATE TABLE data (
id bigint,
user_id bigint,
datetime timestamp with time zone,
);
INSERT INTO users (1,'Australia/Sydney');
INSERT INTO users (2,'Asia/Hong_Kong');
INSERT INTO data (5,1,'2020-04-05 02:00:00');
INSERT INTO data (6,2,'2020-04-05 02:00:00');

and:

"Therefore whatever renders the offset needs to be capable of doing it 
per row, independently of the server/session time zone."

There is no indication of what the server timezone is set to or where 
the timestamps being assigned to date.datetime are coming from. Do they 
originate as local time(per user) or are they being  generated server side?

-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Kevin Brannen
Date:
Subject: RE: can't install pg 12 beta on centos 6
Next
From: Paul McGarry
Date:
Subject: Re: How to get timezone offset in timestamp with time zone AT TIMEZONE output.