pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: Paul McGarry <paul@paulmcgarry.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output.
Date: Tue, 24 Sep 2019 12:44:32 -0700
Message-ID: <91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com> (raw)
In-Reply-To: <87impio1tf.fsf@news-spur.riddles.org.uk>
References: <CAPrE0SYkp12Gd2Y0NVxTwvp_EpMymDa=i_vVQ3EZD11MOSJTRQ@mail.gmail.com>
	<dd0f5c95-08e0-f198-b59a-704377ccdcf7@aklaver.com>
	<87impio1tf.fsf@news-spur.riddles.org.uk>

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





view thread (9+ messages)  latest in thread

Message-ID: <91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com>
Permalink:  ../91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com/
Also on:    postgresql.org/message-id/91469459-36f7-41a4-09e9-c88d693cccef@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, andrew@tao11.riddles.org.uk, paul@paulmcgarry.com
  Subject: Re: How to get timezone offset in timestamp with time zone AT TIME ZONE output.
  In-Reply-To: <91469459-36f7-41a4-09e9-c88d693cccef@aklaver.com>
  References: <CAPrE0SYkp12Gd2Y0NVxTwvp_EpMymDa=i_vVQ3EZD11MOSJTRQ@mail.gmail.com> <dd0f5c95-08e0-f198-b59a-704377ccdcf7@aklaver.com> <87impio1tf.fsf@news-spur.riddles.org.uk> <91469459-36f7-41a4-09e9-c88d693cccef@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