Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qeLhG-006YxJ-DZ for pgsql-docs@arkaria.postgresql.org; Thu, 07 Sep 2023 20:33:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qeLhD-004e5h-T4 for pgsql-docs@arkaria.postgresql.org; Thu, 07 Sep 2023 20:33:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qeLhD-004e5U-Kn for pgsql-docs@lists.postgresql.org; Thu, 07 Sep 2023 20:33:47 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qeLh5-003k8P-69 for pgsql-docs@lists.postgresql.org; Thu, 07 Sep 2023 20:33:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description; bh=/DMoKJIP0uV99tPmpZFi/IHlY7yY2loewLgy47w76NM=; b=NfofE yIy5+LlWPQ7gyngqxnUUpb81uSe7sIS8FzLPR7HJ1XUuxpUHdvXgKqWz8UDi+moxdx2SanIcer3ka B1U2uBEEUpOdygqC9DG10L02+14EHxWC28XWthfbFl+ofCmf5TVgey+33CqlvTyRtmco6X5GU8nip ORrzou7/fMiag2vLBGRxTsW6i387Fx4r8ERsO07AbA87Wk0T4MdEEq7jTkIt8Te49p7pj+ETOky9b +Bk27ckvpyCO5oj/5IHjQUZvKXmKs73+plDmNe1ToUKWh7yP0ShGXYsEcRznp8r+K37GCZNMqlyRw EaA0cUm6eCya4A6b60GtZmB4mVdBw==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qeLh3-00GPtY-0e; Thu, 07 Sep 2023 16:33:37 -0400 Date: Thu, 7 Sep 2023 16:33:37 -0400 From: Bruce Momjian To: davecramer@postgres.rocks, pgsql-docs@lists.postgresql.org Subject: Re: Incorrect/confusing information about timetz Message-ID: References: <168451942371.714.9173574930845904336@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <168451942371.714.9173574930845904336@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, May 19, 2023 at 06:03:43PM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/15/datatype-datetime.html > Description: > > This statement in section 8.5.3 states > "All timezone-aware dates and times are stored internally in UTC. They are > converted to local time in the zone specified by the TimeZone configuration > parameter before being displayed to the client." > Is not correct for timetz Uh, yes to the storage part, no to the output part. ;-) Postgres does store the timetz time zone offset, but it doesn't adust it once it is stored so doesn't adjust for the session time zone: SHOW timezone; TimeZone ------------------ America/New_York CREATE TABLE test (x1 time, x2 timetz, x3 timestamp with time zone); INSERT INTO test VALUES ('09:00:00', '09:00:00', '2023-09-07 09:00:00'); SELECT * FROM test; x1 | x2 | x3 ----------+-------------+------------------------ 09:00:00 | 09:00:00-04 | 2023-09-07 09:00:00-04 SET TIMEZONE = 'Asia/Tokyo'; SELECT * FROM test; x1 | x2 | x3 ----------+-------------+------------------------ 09:00:00 | 09:00:00-04 | 2023-09-07 22:00:00+09 -- -- --- -- --- You can see it stored _internally_ here: ./src/include/utils/date.h typedef int64 TimeADT; typedef struct { TimeADT time; /* all time units other than months and years */ int32 zone; /* numeric time zone, in seconds */ } TimeTzADT; Do we want to document this? -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.