Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTB35-00086e-Nh for pgsql-general@arkaria.postgresql.org; Fri, 08 Nov 2019 20:40:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iTB25-0006uj-By for pgsql-general@arkaria.postgresql.org; Fri, 08 Nov 2019 20:39:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTB25-0006uc-1K for pgsql-general@lists.postgresql.org; Fri, 08 Nov 2019 20:39:01 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTB1w-0006Lq-5F for pgsql-general@postgresql.org; Fri, 08 Nov 2019 20:39:00 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 478sYj3pgWzvx5; Fri, 8 Nov 2019 15:38:49 -0500 (EST) Received: by panix2.panix.com (Postfix, from userid 17622) id 478sYj2xFDz1ZVj; Fri, 8 Nov 2019 15:38:49 -0500 (EST) Date: Fri, 8 Nov 2019 15:38:49 -0500 From: stan To: Adrian Klaver Cc: pgsql-general@postgresql.org Subject: Re: Storing a time interval Message-ID: <20191108203849.GA5401@panix.com> References: <20191108194307.GA16920@panix.com> <143433ed-b3f2-2749-4ae8-d282dcb7f3ce@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <143433ed-b3f2-2749-4ae8-d282dcb7f3ce@aklaver.com> X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Nov 08, 2019 at 12:12:59PM -0800, Adrian Klaver wrote: > On 11/8/19 11:57 AM, Michael Lewis wrote: > > You certainly could choose to store as??tstzrange, but why not use two > > fields? > > > > https://www.postgresql.org/docs/current/rangetypes.html > > I would lean more to a composite type: > > https://www.postgresql.org/docs/11/rowtypes.html > > Range types are built around looking for values within the range, whereas > the OP is looking for two discrete values. The two field method you suggest > above also encapsulates that. > Thanks folks. After thinking over both your sugestions, I beleive teh optimum way to do this may look like: CREATE TYPE po_dates AS ( po_isssued_date timestamptz, discount_last_date timestamptz, net_date timestamptz ); -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin