pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Niels Jespersen <NJN@dst.dk>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: timestamp and timestamptz
Date: Wed, 15 Apr 2020 17:50:08 +0000
Message-ID: <4757e6ae98474a2897b2fac202466e5e@dst.dk> (raw)

Hello all

We have some data that have entered a timestamp column from a csv. The data in the csv are in utc. We want to access the data in our native timezone (CET).

I am considering a few alternatives:


1.       Early in the process, convert to timestamptz and keep this datatype.

2.       Early in the process, convert to timestamp as understood in CET.  This will imply by convention that the data in the timestamp column represents CET. Users will need to be told that data represents CET, even if data is somwhere in the future kept in another country in another timezone.

I probably should choose 1 over 2. But I am a bit hesitant, probably because we almost never have used timestamptz.

Can we agree that the below query is selecting both the original utc timestamps and 2 and 1 (as decribed above)?

set timezone to 'cet';
select read_time read_time_utc, (read_time at time zone 'utc')::timestamp read_time_cet, (read_time at time zone 'utc')::timestamptz read_time_tz from t limit 10;

We are on Postgres 12.

Regards Niels Jespersen

view thread (14+ messages)  latest in thread

Message-ID: <4757e6ae98474a2897b2fac202466e5e@dst.dk>
Permalink:  ../4757e6ae98474a2897b2fac202466e5e@dst.dk/
Also on:    postgresql.org/message-id/4757e6ae98474a2897b2fac202466e5e@dst.dk

 · 

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: NJN@dst.dk
  Subject: Re: timestamp and timestamptz
  In-Reply-To: <4757e6ae98474a2897b2fac202466e5e@dst.dk>
  References: <4757e6ae98474a2897b2fac202466e5e@dst.dk>

* 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