Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOmB1-0001YQ-MF for pgsql-general@arkaria.postgresql.org; Wed, 15 Apr 2020 17:50:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jOmB0-0008T4-Ia for pgsql-general@arkaria.postgresql.org; Wed, 15 Apr 2020 17:50:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOmB0-0008Si-7C for pgsql-general@lists.postgresql.org; Wed, 15 Apr 2020 17:50:18 +0000 Received: from srvimsva2.dst.dk ([91.208.143.64]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jOmAs-0004fG-KP for pgsql-general@lists.postgresql.org; Wed, 15 Apr 2020 17:50:17 +0000 Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43A7F10406F for ; Wed, 15 Apr 2020 19:50:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dst.dk; s=dmz20180119; t=1586973009; bh=KyFVglJq6/8JtQ93xREXa5eTy0w+z96SiVT7tMkdSjE=; h=From:To:Date; b=gRoBS7egVzKkSVM16ZzG77q7w2STwZqDv/8UCvqXlEj5lfA/PTehpeDKAkmg1t7IX LkqZvEFvbzi+vX9Or4FbGn4ZkHSIQxOwJcmp8+xnBfkncUXr/YiXvcfcGGvAu7pidM qcBOBC9rcUVlwJNcnEKd3LF6mIT/cCibDyDMSGyQ= Received: from srvimsva2.dst.dk (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EB6E10406D for ; Wed, 15 Apr 2020 19:50:09 +0200 (CEST) Received: from Sepo.dst.dk (unknown [192.168.64.11]) by srvimsva2.dst.dk (Postfix) with ESMTP for ; Wed, 15 Apr 2020 19:50:09 +0200 (CEST) Received: from srvexc8.dst.local ([172.30.32.48]) by Sepo.dst.dk (JAMES SMTP Server 2.3.2-1) with SMTP ID 99 for ; Wed, 15 Apr 2020 19:50:09 +0200 (CEST) Received: from srvexc8.dst.local (172.30.32.48) by srvexc8.dst.local (172.30.32.48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Wed, 15 Apr 2020 19:50:08 +0200 Received: from srvexc8.dst.local ([fe80::9df8:5de5:1bf2:8b3b]) by srvexc8.dst.local ([fe80::9df8:5de5:1bf2:8b3b%6]) with mapi id 15.01.1847.005; Wed, 15 Apr 2020 19:50:08 +0200 From: Niels Jespersen To: "pgsql-general@lists.postgresql.org" Subject: timestamp and timestamptz Thread-Topic: timestamp and timestamptz Thread-Index: AdYTTjTeodOAuKK2TPefM3+3CcqTSA== Date: Wed, 15 Apr 2020 17:50:08 +0000 Message-ID: <4757e6ae98474a2897b2fac202466e5e@dst.dk> Accept-Language: da-DK, en-US Content-Language: da-DK X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.22.69.7] Content-Type: multipart/alternative; boundary="_000_4757e6ae98474a2897b2fac202466e5edstdk_" MIME-Version: 1.0 X-TM-AS-GCONF: 00 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_4757e6ae98474a2897b2fac202466e5edstdk_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 datatyp= e. 2. Early in the process, convert to timestamp as understood in CET. = This will imply by convention that the data in the timestamp column represe= nts 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 becaus= e we almost never have used timestamptz. Can we agree that the below query is selecting both the original utc timest= amps and 2 and 1 (as decribed above)? set timezone to 'cet'; select read_time read_time_utc, (read_time at time zone 'utc')::timestamp r= ead_time_cet, (read_time at time zone 'utc')::timestamptz read_time_tz from= t limit 10; We are on Postgres 12. Regards Niels Jespersen --_000_4757e6ae98474a2897b2fac202466e5edstdk_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello all

 

We have some data that have ent= ered 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 alternat= ives:

 

1. &nbs= p;     Early in the process, c= onvert to timestamptz and keep this datatype.

2. &nbs= p;     Early in the process, c= onvert to timestamp as understood in CET.  This will imply by conventi= on 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 timez= one.

 

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

 

Can we agree that the below que= ry is selecting both the original utc timestamps and 2 and 1 (as decribed a= bove)?

 

set timezone to 'cet';

select read_time read_time_utc,= (read_time at time zone 'utc')::timestamp read_time_cet, (read_time at tim= e zone 'utc')::timestamptz read_time_tz from t limit 10;<= /p>

 

We are on Postgres 12.

 

Regards Niels Jespersen

--_000_4757e6ae98474a2897b2fac202466e5edstdk_--