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 1vC4fA-008fDl-OG for pgsql-general@arkaria.postgresql.org; Thu, 23 Oct 2025 23:24:08 +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 1vC4f8-00CWk1-IV for pgsql-general@arkaria.postgresql.org; Thu, 23 Oct 2025 23:24:05 +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 1vC4f8-00CWiy-7o for pgsql-general@lists.postgresql.org; Thu, 23 Oct 2025 23:24:05 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vC4f5-003Qyn-1b for pgsql-general@lists.postgresql.org; Thu, 23 Oct 2025 23:24:04 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-33ba37b3ff7so1410800a91.1 for ; Thu, 23 Oct 2025 16:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761261842; x=1761866642; darn=lists.postgresql.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=sapH6EwogBvGeFIYqCQdTQ4jUJpP0Gzq+UMXnDisRhE=; b=OlzNtk+kY7IPuAFCSjMBDOL3QRWHayfIq1D0zlQtHmdF1Pws4sPJ28EUOXUnh+mgUd VqysGVP+GPvIiCKRH49enrdCegbgkDjScGKfwUiZULSDEx1gp01TXlqcOXWNFKOpSYWM RDmvQqX74zAUSF2yN8uLoyImBbfyoU61qxElGVftI6I76vrOb7QLCHKMaXsGLmxL50lj Kema5GXNRoFI669/KOIf32lji6/bZfBsJLcAtC6XU/zHj99IZtV0enjBcg8D/AQER3ZW Rz57tvPqd/CVdH55gQLNHVpS/xJNuvROmXZu3WYrmYiJlImKaP+zOk4qj4WW7GHEcNgc +Wdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761261842; x=1761866642; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sapH6EwogBvGeFIYqCQdTQ4jUJpP0Gzq+UMXnDisRhE=; b=OJ5qFAiMI7TeWm6ArqyM7xxHjDhUrEcMYRx35k17zOQ/LT/k3v7ZS9KxvRtZwtOJs3 HfEUX3mJ/tAmd4JKmXCgPV/RSfJKrSdEaebTWS0pLc/hB3Z1cuWZcMhKdW76CWNh4e0J zaDnZJ7ekm0eWSOMlc45S16FbFEBKm0lMffaCncx2J4TZFueQfOtdfDzC9UgC4JTKVgs ahFAc6Trtm6MeL8wL/ptKvgbpb5W37m/zLylyREIinOLIbdYRkY1GspFEtEKLocbzFpI /NFYBFJJIq+iDqKAqkAZTxIlv45WzaTd0Wnqqfz/92uYZqHmWPOQWgYD5PD+5ux0lSNr jNzw== X-Gm-Message-State: AOJu0YzhQjdp8kbhc5nSFgGVMHg2Xw8az955Kg70vfVTFLf6zS26iUKB T4x29L+nCrQTO+dBq9pdvAlKn/TySKQ2LagLGBKZFw0335GYnbXkx97aYVos/WqH X-Gm-Gg: ASbGncs7mjxwr49GTmyvGwBlahi8CpOKnBiya7icZ14H7pJGkrK2+k2degmyPag3wBJ Mh4vMvga2Fp3wfV+SmkoiAU4EJD/a0YhpQKpOKe2QPPiQj762nfuegWvqHpVnb8+KX8lQ5g/3EY 7osT82PFntQK+4dI4b3XV9+VnpEb+oKkd2zFDlpjV/PeJ4wBmAtAtT3NX6S43l5X+DLdxa7gBtr waIlahHigPg/S4XuP/PU3vBgjzwLUt/9n8zwsyT19MHqcAM+J8OQtP3dJxVNgUAg8DIXL1JPoFn RknCYY67UUSRDeV3HOI8/i0IaxVGkbx+Z4BjZwVBGB78M+MRn5sElyFzEpaeOS+MSi9cKSdAbiA NHfdlA/7pVgpdEtEataVxq0rSP5f8QHeeJMaMaoj802NblfzIIog+EfAUpWbg5qeZ17EHUgvkBV C0Di7OnXqjCBYMOLH8aD3Ctg== X-Google-Smtp-Source: AGHT+IE4QFM7GYWRI4cgD5XtCanmHkbyW/PnvKfdltPf3KrIxkvj+Ivg7UQqNknbuZGSRAHwCMiIHA== X-Received: by 2002:a17:90b:4a8a:b0:32e:11cc:d17a with SMTP id 98e67ed59e1d1-33fd3a0cc41mr787686a91.4.1761261841876; Thu, 23 Oct 2025 16:24:01 -0700 (PDT) Received: from smtpclient.apple ([15.220.16.55]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-33e224a2652sm7113611a91.18.2025.10.23.16.24.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Oct 2025 16:24:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Rob Sargent Mime-Version: 1.0 (1.0) Subject: Re: Convert date and time colums to datetime Date: Thu, 23 Oct 2025 17:23:50 -0600 Message-Id: <600867CF-E73A-4899-9679-209BF69FE329@gmail.com> References: Cc: pgsql-general@lists.postgresql.org In-Reply-To: To: "Peter J. Holzer" X-Mailer: iPhone Mail (22G100) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 23, 2025, at 1:52=E2=80=AFPM, Peter J. Holzer wr= ote: >=20 > =EF=BB=BFOn 2025-10-20 06:43:17 -0600, Rob Sargent wrote: >>=20 >>=20 >>>> On Oct 20, 2025, at 5:05=E2=80=AFAM, Peter J. Holzer = wrote: >>>=20 >>> =EF=BB=BFOn 2025-10-19 20:32:07 -0600, Rob Sargent wrote: >>>>>> On Oct 19, 2025, at 2:38=E2=80=AFPM, Rich Shepard wrote: >>>>> On Sun, 19 Oct 2025, Rob Sargent wrote: >>>>>> I think you have to ask why those values were separated in the first >>>>>> place. For instance if they are thought of as a pair in most queries t= hen >>>>>> an alteration might be in order. There can be a large one time cost i= f >>>>>> these tables occur in a lot of separate sql calls in the business log= ic. >>>>>=20 >>>>> Good point. They're in the contacts table and I use them to determine w= hen >>>>> to make another contact and if prior contacts were more productive in t= he >>>>> morning or afternoon. >>>>=20 >>>> Definitely a datetime (single value) problem, imho >>>=20 >>> Actually, to me that seems to be one of the few cases where splitting >>> them makes sense. I would expect typical updates to be something like >>> "sane time, but 6 months later" or "same day, but different time". There= >>> might also be constraints like "not before 9am". For queries there might= >>> be stuff like "who do I need to call today", or as Rich already >>> mentioned, statistics by time of the day. There are probably relatively >>> few queries where you need to treat date and time as a unit. >>=20 >> Which of your example updates cannot be done with timestamp? Perhaps >> the =E2=80=9Cnot before=E2=80=9Dconstraint but can that be done with OP=E2= =80=99s design? >> Maybe the time column is an interval? >=20 > The question isn't IMHO whether it *can* be done. Obviously a certain > point in time can be represented by a timestamp or a date/time pair and > both will work (as will a whole lot of different representations). The > question is what feels more "natural" for the given application. Are > the date and the time often used independently or are they almost > always used as an atomic entity? My impression from what Rich wrote > is that it might be the former. Which would suggest also storing them > independently. Not saying that this is necessarily the right thing to > do but isn't "definitely a datetime (single value) problem" either. >=20 > hjp >=20 Agreed.=20 My position is that I would have started with timestamp. OP is welcome to ch= oose what works best for him. Certainly not seriously advocating the alter t= able and related effort at this point.=20 > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp@hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" >