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.96) (envelope-from ) id 1vxS4O-00EmED-1c for pgsql-general@arkaria.postgresql.org; Tue, 03 Mar 2026 15:54:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vxS4M-007hnq-36 for pgsql-general@arkaria.postgresql.org; Tue, 03 Mar 2026 15:53:59 +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.96) (envelope-from ) id 1vxS4M-007hni-0B for pgsql-general@lists.postgresql.org; Tue, 03 Mar 2026 15:53:59 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vxS4K-00000000CQT-1XIK for pgsql-general@lists.postgresql.org; Tue, 03 Mar 2026 15:53:57 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 2AF941400191; Tue, 3 Mar 2026 10:53:55 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 03 Mar 2026 10:53:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1772553235; x=1772639635; bh=iw/T4dPaUrs8eKtREDCAmjJzNO5cNTjalTzlsB+pRt8=; b= S4p826tYY3wT15gf3F496ZupYgZT3yCoVu2jTBOP97I6upCr/rTS2Mt3rTXMBuFP d9YGN3m7rsQRSo+wCubft6lgSAhIMLjJGmJvThy8UIFS+f9V8JO+NI3EpNxcNPdT d2hr1Uq/gNW0h4ZPC20ZOrN15c34co3CG4Y2GP0m3lf4hGvOuc2qTDyKqNmR5v4E EbE7P1n17cD5hdO+OUwzsxEOcwCUj8eF/TqlhrtRhKd9s5MfUri/pkZsklUjSAIW C9QyNZ8kF/rgF7yjTvPDCotPn9hjmTqP/MujO4um2JZi7GsWFrqshamHfa8a84yD E2pjC4bGV0zZ6Aym6fS4TQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1772553235; x=1772639635; bh=i w/T4dPaUrs8eKtREDCAmjJzNO5cNTjalTzlsB+pRt8=; b=Bol2oYekiO1vsJJzX Cxf3IkGYNWZa4LPSPQHWhMbdeCrkWjH7zSzmGNQjD1+3Q+44Ra/i3qh4dOY7VTxg mV0//DW7ncbd7q4bZ7bINI+DMy0j7E4OyRNg1rgFBs3u/yydHrZqzV0FwJAzPTug /CgTr9snUbUMEzb+jbNB/xB+4tc2NONofxyXHbnqNmdEhXJ0wBnZGxG8ixVX5uz9 NfwETJe17TCPFAo3wojGF+ZJEDFCxVDzwDlXxd432kcsLIgy3NjBp4IzWXt3/sV4 Qat3Ni9ml5S97xykrw24sQ7P+BZDCyTGenDrT67Tkavpvd7PoaGmAb/4hNP1m5+6 Qh5vA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddviedtleelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhirghn ucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqe enucggtffrrghtthgvrhhnpeelgeevkeekkeeuiefgtdevieeluefhfedufeetkeejffek jeeujeehgeehgeektdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepfedpmhhoug gvpehsmhhtphhouhhtpdhrtghpthhtohepnhgrnhguihhshhdrsghhuhhvrgesshhrmhhs ohhfthifrghrvghinhgtrdgtohhmpdhrtghpthhtoheplhgruhhrvghniidrrghlsggvse gthigsvghrthgvtgdrrghtpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Mar 2026 10:53:54 -0500 (EST) Message-ID: <03158640-b768-4d9f-90ce-6a30029febc2@aklaver.com> Date: Tue, 3 Mar 2026 07:53:53 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Timezone handling with timestamp without time zone columns To: Nandish Bhuva , Laurenz Albe , "pgsql-general@lists.postgresql.org" References: <8c3b8558fc3322c31d9f05517dcdb43e16296fa0.camel@cybertec.at> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/3/26 2:10 AM, Nandish Bhuva wrote: > Adding pgsql-general@lists.postgresql.org +++ > > Regards, > Nandish Bhuva > ------------------------------------------------------------------------ > *From:* Nandish Bhuva > *Sent:* Tuesday, March 3, 2026 3:01 PM > *To:* Laurenz Albe > *Subject:* Re: Timezone handling with timestamp without time zone columns > @Laurenz Able > > Thank you for your response and for clarifying that the issue stems from > how the timestamps are being stored rather than from PostgreSQL itself. > Unfortunately, the application is quite large and complex, and at this > time we are not in a position to modify the column definitions or update > the stored data. Therefore, we are looking for a solution that allows us > to handle the timezone conversion purely at the query level using | > SELECT|, without altering the table structure or existing data. > As mentioned previously: > > * > |empjob_utc_update_date| stores UTC values (but is defined as | > timestamp without time zone|) > * > |jstsk_lst_end_tm| stores Canada/Pacific local time (also |timestamp > without time zone|) > > Our goal is to convert both timestamps to a common timezone (for > example, UTC) within the query itself to ensure accurate comparison. > I attempted the following: > Your guidance on the proper |AT TIME ZONE| usage for |timestamp without > time zone| columns would be greatly appreciated. > Thank you again for your assistance. 1) I would strongly suggest you read: https://www.postgresql.org/docs/current/datatype-datetime.html 8.5.1.3. Time Stamps 2) Assuming the server is set to Canada/Pacific time: -- My Ubuntu instance does not have Canada/Pacific set timezone = 'America/Vancouver'; select '2025-03-03 07:44'::timestamp, ('2025-03-03 15:44'::timestamp AT time zone 'UTC')::timestamp; timestamp | timezone ---------------------+--------------------- 2025-03-03 07:44:00 | 2025-03-03 07:44:00 Where the first timestamp is just left alone as it is in local time and the second is defined as being at UTC and then rotated to local time and has the time zone offset stripped off by the cast to timestamp. > Regards, > Nandish Bhuva > Yours, > Laurenz Albe -- Adrian Klaver adrian.klaver@aklaver.com