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 1sRBjZ-00Dm18-TU for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jul 2024 14:22:22 +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 1sRBjY-00Fmgk-73 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jul 2024 14:22:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRBjX-00Fmgc-NF for pgsql-hackers@lists.postgresql.org; Tue, 09 Jul 2024 14:22:19 +0000 Received: from pb-smtp2.pobox.com ([64.147.108.71]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRBjU-001DAK-A3 for pgsql-hackers@lists.postgresql.org; Tue, 09 Jul 2024 14:22:17 +0000 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id EF9F92A1EC; Tue, 9 Jul 2024 10:22:14 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=sasl; bh= TaBYACpqXipuiS6vlI9iThZfWsCH4EJ3wIBytT1iw0I=; b=IPosHWKVdJHlVcVs aSb+B24BOz27IVJgbaOogW5i6m9hfUi5gP2MQGnJTOIr78BMcAvunW0x7pBraK2v vC95+YXSqF4pmdDYb5u5nGxckuDAs48LQQDnnJJlR6/2ne8Xzism1co2IwyC4Bql hBKybc+xuMTB18YoPGkMsHimTM8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id E77722A1EB; Tue, 9 Jul 2024 10:22:14 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=justatheory.com; h=content-type:mime-version:subject:from:in-reply-to:date:cc:content-transfer-encoding:message-id:references:to; s=2016-12.pbsmtp; bh=TaBYACpqXipuiS6vlI9iThZfWsCH4EJ3wIBytT1iw0I=; b=cJYJbCF6NcPGk5X9x15EPY38QLQAZk9ZaKfxA0+ERdhwzbnPt/fO77D3m6D14lmDVMA2128ERz1ySuiqRZFXNqr5BZ6v81zuK9L1ZVo/cHn9o5TylAo9gtUjnipwfKGYFv/qMt8qmVuFObcVOhBOy8ulOkgVQoUdkmyXYFEw97o= Received: from smtpclient.apple (unknown [158.222.197.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 68FC82A1EA; Tue, 9 Jul 2024 10:22:14 -0400 (EDT) (envelope-from david@justatheory.com) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: jsonpath: Inconsistency of timestamp_tz() Output From: "David E. Wheeler" In-Reply-To: <53E4B67F-70FF-441E-A48B-DE520966A312@justatheory.com> Date: Tue, 9 Jul 2024 10:22:03 -0400 Cc: PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <7DE080CE-6D8C-4794-9BD1-7D9699172FAB@justatheory.com> <53E4B67F-70FF-441E-A48B-DE520966A312@justatheory.com> To: Junwang Zhao X-Mailer: Apple Mail (2.3774.600.62) X-Pobox-Relay-ID: A37264F8-3DFE-11EF-804F-965B910A682E-76319746!pb-smtp2.pobox.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Jul 9, 2024, at 10:07, David E. Wheeler = wrote: > So perhaps I had things reversed before. Maybe it=E2=80=99s actually = doing the right then when it converts a timestamp to a timestamptz, but = not when it the input contains an offset, as in your example. To clarify, there=E2=80=99s an inconsistency in the output of = timestamp_tz() depending on whether the input has an offset or not. With = offset: david=3D# select jsonb_path_query_tz('"2024-08-15 12:34:56-05"', = '$.timestamp_tz()'); jsonb_path_query_tz =20 ----------------------------- "2024-08-15T12:34:56-05:00" And without: david=3D# select jsonb_path_query_tz('"2024-08-15 12:34:56"', = '$.timestamp_tz()'); jsonb_path_query_tz =20 ----------------------------- "2024-08-15T16:34:56+00:00" I suspect the latter is correct, given that the timestamptz type appears = to be an int64, presumably always in UTC. I don=E2=80=99t understand = where the first example stores the offset. Best, David