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 1vvzLB-00E6f0-3D for pgsql-general@arkaria.postgresql.org; Fri, 27 Feb 2026 15:01:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvzLA-004Cwi-2x for pgsql-general@arkaria.postgresql.org; Fri, 27 Feb 2026 15:01:16 +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.96) (envelope-from ) id 1vvzLA-004CwY-1r for pgsql-general@lists.postgresql.org; Fri, 27 Feb 2026 15:01:16 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vvzL7-00000001aP9-3LwC for pgsql-general@lists.postgresql.org; Fri, 27 Feb 2026 15:01:16 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-48370174e18so12480585e9.2 for ; Fri, 27 Feb 2026 07:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1772204473; x=1772809273; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CaOqxn2mk/mQmsxzqIFVQBhfBpF6kspgM9mUChgbyF0=; b=MdOrPnjSWhUtjcyogqQ+kvblw/V8Q1rYhdFAcyBhmsf4nwnh/O4U4JcDD3Oto46Zk7 Kb3RztQ623Cj3Uj51AIClJQl9KV/LsnezQ/EneiOz1ZFK1PJRY4/rPcm0Q47XXJNOQkq u6Kn4FfEi7kr5QVi66CL+Z3XJWtdTQKDRgiCJWl/ht3HQDDqR97ctkk+Md0cgIDJ3UXt uSbr7eEXqCeXpjqwNyNLx4zYJj5ojVhJWsXeqeJulv5yG9DsRxlby8Luqbx47cxszdoT 94GZ89okF6pVk5aU7ekwTmtVwAnE7RPGNbjIS/irDYksN7oDOOLJLzayReudkNYmbq7Y ogxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772204473; x=1772809273; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CaOqxn2mk/mQmsxzqIFVQBhfBpF6kspgM9mUChgbyF0=; b=pRhi7qxX1jhucIRu28zxWmnuD1AVdFkczkK9rprNZjCHYtpJqFiOEYetMUusXXeHWn 87UWMbowl5z3tAPqqoe2ItcZD0Dpsemi964MaxqPqtIMqmhPX4+x/qgSc79Iv+SSe4Ym xc2wuePIVUot6ZvqTeRFM0+C6fk1ztjp4ocdFRNTiQOLbjU8VNt0KJHYKfODMNotRbRA UaqiNOnMTuIT/2c6oAm2lCTYg4iNP8QvyfUfd4inwwGA+NLZL81CwG96tOozRhxgWM4V zNLEb7SUrw9oSv9zSL5BdpupoycqnNU/Bxw/K0eDTAPbCnVFmJj5TUsKW1Q6bhQ8eFMS 1PuA== X-Forwarded-Encrypted: i=1; AJvYcCWeMbECZLJ5qDZWi7PQYRUwm7LWceS950f0a1ML/y+LoduqEfG7sMSS7Ka4kzyRlwouZ/2H9LnHAVfyzBiD@lists.postgresql.org X-Gm-Message-State: AOJu0Yz3A4LHyXmro5LcKtaw2joff+WG1i0+I4ktqpGJtZ5Y0pOX4hY7 NMW+bXxTacmewp8h4ERXP5WOujOqUv8Pj0db5aIq4FeUPiMzyNouNwMNN/l7it7FggM= X-Gm-Gg: ATEYQzyTSza0/MaqIO+eoHIwLR8vcKwxoQVJZKaU6WUmiUE4tyrflvNiKyteqKW1ynj 2xOr2KBA51k4kmwO+4maewrluIaM0mPTIXdckxRfWo1l955roG0hQw8az8WVVSZ5RearaSOYVeB 7oej8+/fYSbn3GIYQNtyniZ5Fi29x7IHRlGycP0zJH3ODkEgdAxvRzKDqdYWRbjU8DsBy8maGgq clhFDGvnKVOzG3VKCQ0Vuug7v6+bBPmiRBBXghg8b9KaoNhGwJFims1uvzOc5wuX9CSBu6V52eR PgFEHBVoys/4FgeI8lbia+dhQcob+kraGUtFiEqK1oSGnBJz4ERxxRoaqbqfShQq53k3lzw4sUx kDfCmOjmSu6rB2eoD/PhHw7+DBQfWlKey4AU8uMkqtdLG53DYIrZa8fFE8v5cdXqZ9Gn0bxqdGJ 8Hou4XZp85QB8ohLBLuT812bsMYZAmkAdp81QUP+J7GzVR9wpepJcYhP9oblK/Yqo= X-Received: by 2002:a05:600c:a085:b0:483:badb:618f with SMTP id 5b1f17b1804b1-483c9bc5b7dmr45459935e9.25.1772204473127; Fri, 27 Feb 2026 07:01:13 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:9a2c:17c4:94e7:857c:de9e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c75a25dsm7253698f8f.21.2026.02.27.07.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Feb 2026 07:01:12 -0800 (PST) Message-ID: <8c3b8558fc3322c31d9f05517dcdb43e16296fa0.camel@cybertec.at> Subject: Re: Timezone handling with timestamp without time zone columns From: Laurenz Albe To: Nandish Bhuva , "pgsql-general@lists.postgresql.org" Date: Fri, 27 Feb 2026 16:01:10 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2026-02-25 at 08:28 +0000, Nandish Bhuva wrote: > I would like to report a timezone-related issue we are encountering in ou= r PostgreSQL database. To avoid misunderstandings: thsi is not a problem of PostgreSQL, but a user= -created problem, right? > We have two columns: > =C2=A0* empjob_utc_update_date > =C2=A0* jstsk_lst_end_tm > > Both columns are defined as=C2=A0timestamp without time zone. > Currently, we are observing the following values: > =C2=A0* empjob_utc_update_date =E2=86=92=C2=A02026-02-19 06:26:23.830811 > =C2=A0* jstsk_lst_end_tm =E2=86=92=C2=A02026-02-19 01:23:46.016 > > Our entire application runs in the=C2=A0Canada/Pacific=C2=A0timezone. How= ever, when comparing > these two timestamps in our queries, we are getting incorrect results in = the system. > It appears that: > =C2=A0* empjob_utc_update_date=C2=A0is effectively storing UTC time. > =C2=A0* jstsk_lst_end_tm=C2=A0is storing Canada/Pacific local time. To reiterate: *you* are storing the data in the columns in this way. > =C2=A0* Since both columns are defined as=C2=A0timestamp without time zon= e, PostgreSQL does not > apply any timezone conversion during comparison, which is leading to l= ogical > inconsistencies. > > We would like clarification on the recommended approach to handle this sc= enario. Specifically: > =C2=A0=C2=A0=C2=A01. Should both columns be converted to=C2=A0timestamp w= ith time zone If you are operating only within a single time zone, it doesn't matter. You just have to be consistent about how you store timestamps. > =C2=A0=C2=A0=C2=A02. Give me best solution for without even changing the = column datatype. You can fix the incorrectly stored data with UPDATE tab SET empjob_utc_update_date =3D empjob_utc_update_date AT TIME ZONE 'UTC' AT TIME ZONE 'America/Chicago'; That will convert UTC timestamps to Chicago timestamps. > Please advise on the best practice to ensure consistent timezone handling= and accurate > comparisons going forward. The best practice is that you store tmestamps in a consistent fashion: either - use "timestamp with time zone", store timestamps with time zone and make sure that the parameter "timezone" is set correctly in each database session or - use "timestamp without time zone" and store only Chicago timestamps without a time zone Yours, Laurenz Albe