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 1mSlma-0002kN-Dm for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 19:50:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSlmZ-0007DT-3D for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 19:50:23 +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 1mSlmY-0007DK-Qd for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 19:50:22 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSlmP-0008Kx-SZ for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 19:50:21 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 760475343; Tue, 21 Sep 2021 21:50:12 +0200 (CEST) Date: Tue, 21 Sep 2021 21:50:12 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Timestamp with vs without time zone. Message-ID: Mail-Followup-To: pgsql-general@lists.postgresql.org References: <4a195869-f9ed-c39b-4070-e882b546d7fd@aklaver.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3ySv2zuE4TrZRYzn" Content-Disposition: inline In-Reply-To: <4a195869-f9ed-c39b-4070-e882b546d7fd@aklaver.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3ySv2zuE4TrZRYzn Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-09-21 12:37:49 -0700, Adrian Klaver wrote: > On 9/21/21 11:45 AM, Peter J. Holzer wrote: > > On 2021-09-21 13:43:46 -0400, Dave Cramer wrote: > > > On Tue, 21 Sept 2021 at 13:40, Peter J. Holzer wro= te: > > > On 2021-09-21 13:34:21 -0400, Dave Cramer wrote: > > > > I would say this is a perspective thing. It's a timestamp with= a time > > > > zone from the client's perspective. > > >=20 > > > I disagree. When I read back the value the original timezone is = lost. So > > > it clearly DOESN'T store the timestamp WITH the timezone. > > >=20 > > >=20 > > > I never said it stored the timezone.=C2=A0 I said that it has a timez= one. > >=20 > > The raison d=E2=80=99=C3=AAtre of a database is to store data. If some = data isn't > > stored, the database doesn't have it, in my opinion. > >=20 >=20 > But if you use timestamptz it does have it. No. > The data(timestamp) is stored with time zone UTC. From there you can > reconstruct the timestamp at any time zone you want, given the clients > needs. I'm not sure why where it started is important when people care > how it is presented to them on retrieval. Whether it is important or not is besides the point. It isn't there and it cannot be reconstructed. If you need it, you have to store it separately. hjp=3D> set timezone to 'America/Chicago';=20 SET hjp=3D> insert into t values('2021-03-01 04:15');=20 INSERT 0 1 hjp=3D> set timezone to 'Europe/Vienna';=20 SET hjp=3D> insert into t values('2021-03-01 11:15');=20 INSERT 0 1 hjp=3D> select * from t;=20 =E2=95=94=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=97 =E2=95=91 t =E2=95=91 =E2=95=9F=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=95=A2 =E2=95=91 2021-03-01 11:15:00+01 =E2=95=91 =E2=95=91 2021-03-01 11:15:00+01 =E2=95=91 =E2=95=9A=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=9D (2 rows) These two values are completely indistinguishable. That's good for a timestamp (they are the same time after all). But they are not a "timestamp with time zone". The time zone is not part of the value but of the environment. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --3ySv2zuE4TrZRYzn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmFKN3AACgkQ8g5IURL+ KF3MWxAAgaUrhbI9OMtm2ztSQyKwYKKPheBvpHbPzWsuAilAUmDqUH7itn+QqJkf Z0jmENIK2dU/32upCBkzkubF2/sWLIp0PZ25hmKpNSThEsqjK9ywAxj6UA5ZpA9L RT+HcvbN8oHGEe9MJ7v5aaYOsLCQgNGPAGg/6gHBICMVAscnzgdeOuzTU5msB1W7 w+DWY0Z6EX2b7ckwEvbyfpD3w5VO7FSbtbo5oBpeyi8GrgB3nIyqylVBXC4D/ZVJ YWeLsUtXTkDeuHpKbmCt5qeiAP9MQnLXEsc7K3gWLqF4gz8uM0EZTptR02c1qrff A8oBpB8SU8AN4vQltxNFDomj/0THO69YsL9CHE/Vg+n4ITu5jNwaOCa7b4AfNHZW +vPnOS4K/Vc/m/CltkeZkkWcvBoNOdWgauGJUE49NDXX1Hz1qtO2E3fVZAX7qO13 zNt2+wNHxA+vf+JLJoMj3GxUeuHCHh6MPn5h4T2LkLSNNz4vBlaercFFNxqKbG0j tY53PJroNJOA1T/bgNC0rOPGGs9uC9RUTUTMo7gwndBToL3z5r9HCKkhNOZYDcGX s/q1IBQ7S/cOS/DN8Z2lkqLhE2yCl0+068P34DOE7grzU5/WQ8S7ZifIcnjJxzr/ av9VWGLBrK1m1G+i/UkdOPZG6lxpd/Uc5Y6n0nf6EEhTKXDdSCs= =gjLL -----END PGP SIGNATURE----- --3ySv2zuE4TrZRYzn--