Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbSr4-0002IF-Bc for pgsql-general@arkaria.postgresql.org; Fri, 15 Oct 2021 19:26:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mbSr3-0001jO-1L for pgsql-general@arkaria.postgresql.org; Fri, 15 Oct 2021 19:26:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mbSr2-0001jF-Kk for pgsql-general@lists.postgresql.org; Fri, 15 Oct 2021 19:26:56 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mbSqz-0001om-9B for pgsql-general@lists.postgresql.org; Fri, 15 Oct 2021 19:26:56 +0000 Received: by mail-pg1-x52d.google.com with SMTP id m21so9425551pgu.13 for ; Fri, 15 Oct 2021 12:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=wvGUvSesEFvRv8lVGiwxQ6E+vK6VKhMrdpCzIdHDYzE=; b=jaETsllc3jTfCJNxQbOmB7JelQX0unfzGd2AEPpk9YbwVwd8aq4qpdpcNz1QuCVIZ5 TLJTvxXMoIKPci932rmFxlPvzUZ1YQWXnhJVAG6b9OVhHJTY2QPRpJ1/GKAgOTyXtV5+ GkMveztA3kuh6veYSaua/89IpdhWeH/9qt7gIEc/VgbDK1SYhNR+BgO7wfSTnAjS2bZ6 SGnSGM4VE//lNXK65P0SUNcvGZTTEDssqlZ0HZ/jCzH71N+zYbOiNzOY4lxRra+4dPWE k9qBCEuKpfpiGt/Tm4Ef67FMSQx6db3fs5kXQN5Fx8YLXuXUc79HoJ9BHZQY2AdCdNZ9 71DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=wvGUvSesEFvRv8lVGiwxQ6E+vK6VKhMrdpCzIdHDYzE=; b=ZdgEbt/Q5zeZdTMl/3Pc5pC28PmfCA3vdNvNC6zED3rNAblRTZQBhUvuBLl8uUg8bV LxtKmIdD6tPeJvc3HYsCdj2PiB+T6X06NSx1T1+cPUJG79q9n2RJrXbgsziuB1cAGScm Cuv7Yzl+y6et5sc8xO4J2/FAJ37jdUT8WNmyrJcjeH2ck1UOZ28yG1xUzcuQKVZlBvSK GtjBhbQFoSlhQXytbnCn0nI7Oo4hyKh1drGplAmgZy6O20GNf4lJ4wB3l8NmC7QqP3f0 YfW7DqcdmR5Co9yuPfNqgRiEYrZBguktKWf9zMxf6IuWvWu8Xaa9mKl82xw5XGkTk6Q3 IEug== X-Gm-Message-State: AOAM533VGDP8EuEdMrmGdp4ZAEQuQhUdMN5PxwDxdtt3EH4Xq6q5YWeF BzjexdGIcr8Rz5zaR67GTQI= X-Google-Smtp-Source: ABdhPJxH56UeF0L85UOJwIvojkZXQj/Xcx4rng3OGa64i3D5vBBVvi++g9EklzFczRHOK+yF99xkYg== X-Received: by 2002:a63:fc65:: with SMTP id r37mr10615674pgk.28.1634326010889; Fri, 15 Oct 2021 12:26:50 -0700 (PDT) Received: from [2600:8801:8800:2:100::] ([2600:8801:8800:2::9]) by smtp.gmail.com with ESMTPSA id b8sm5897655pfm.65.2021.10.15.12.26.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Oct 2021 12:26:50 -0700 (PDT) Date: Fri, 15 Oct 2021 12:26:42 -0700 From: Guyren Howe To: Ron , Brian Dunavant Cc: "pgsql-generallists.postgresql.org" Message-ID: In-Reply-To: References: <820B633E-90C6-40F0-81A0-CAA074E5762F@yugabyte.com> <2ff5f521-34ab-8690-180a-864441e4f15b@aklaver.com> <0782c52d-2a80-b37f-0b9e-1a2a7cfb68c5@gmail.com> <98ea7ea3-38ac-d145-e668-803e5ea14de7@aklaver.com> Subject: Re: "two time periods with only an endpoint in common do not overlap" ??? X-Readdle-Message-ID: bf07115a-0404-498a-ab7c-da1df62adf17@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="6169d5f8_515f007c_24a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --6169d5f8_515f007c_24a Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I=E2=80=99m a bit confused by this conversation. Open- and closed-ended r= anges behave as I would expect. select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '=5B)') && tsrange= ('2016-01-11 17:00', '2016-01-12 17:00', '=5B=5D') false select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '=5B=5D') && tsran= ge('2016-01-11 17:00', '2016-01-12 17:00', '=5B=5D') true On Oct 15, 2021, 11:27 -0700, Brian Dunavant , wrot= e: > Think of it this way.=C2=A0 When someone says they have a meeting from = 1-2 and another from 2-3, do those meetings overlap=3F=C2=A0 They do not,= because we're actually saying the=C2=A0first meeting is from 1:00 throug= h 1:59:59.99999.=C2=A0 =C2=A0The Postgres date ranges are the same way.=C2= =A0 =C2=A0The starting point is inclusive, but the ending time is exclusi= ve.=C2=A0 =C2=A0So =5B1:00,2:00), and =5B2:00,3:00), do not overlap. > > > On =46ri, Oct 15, 2021 at 2:16 PM Ron wro= te: > > > On 10/15/21 8:59 AM, Adrian Klaver wrote: > > > > On 10/15/21 06:52, Ron wrote: > > > >> On 10/14/21 7:02 PM, Adrian Klaver wrote: > > > >> =5Bsnip=5D > > > >>> or the third example in the docs: > > > >>> > > > >>> SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS > > > >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (DATE '2001-10-30', DATE '= 2002-10-30'); > > > >>> Result: true > > > >>> SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS > > > >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (DATE '2001-10-30', DATE '= 2002-10-30'); > > > >>> Result: false > > > >>> SELECT (DATE '2001-10-29', DATE '2001-10-30') OVERLAPS > > > >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (DATE '2001-10-30', DATE '= 2001-10-31'); > > > >>> Result: false > > > >> > > > >> Why /don't/ they overlap, given that they share a common date=3F= > > > > > > > > Per the docs: > > > > > > > > https://www.postgresql.org/docs/current/functions-datetime.html > > > > > > > > =22 Each time period is considered to represent the half-open int= erval start > > > > <=3D time < end, unless start and end are equal in which case it = represents > > > > that single time instant.=22 > > > > > > > > Which I read as > > > > > > > > (DATE '2001-10-29', DATE '2001-10-30') ends at '2001-10-29' > > > > > > > > and > > > > > > > > (DATE '2001-10-30', DATE '2001-10-31') starts at DATE '2001-10-30= ' > > > > > > > > so no overlap. > > > > > > I was afraid you were going to say that.=C2=A0 It's completely biza= rre, but seems > > > to be a =22thing=22 in computer science. > > > > > > -- > > > Angular momentum makes the world go 'round. > > > > > > --6169d5f8_515f007c_24a Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I=E2=80=99m a bit confused by this conversation. Op= en- and closed-ended ranges behave as I would expect.

select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '=5B)') &&= tsrange('2016-01-11 17:00', '2016-01-12 17:00', '=5B=5D')
false

select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '=5B=5D') &&am= p; tsrange('2016-01-11 17:00', '2016-01-12 17:00', '=5B=5D')
true
On Oct 15, 2021, 11:27 -0700, Brian= Dunavant <dunavant=40gmail.com>, wrote:
Think of it this way.&=23160; When someone says they= have a meeting from 1-2 and another from 2-3, do those meetings overlap=3F= &=23160; They do not, because we're actually saying the&=23160;first meet= ing is from 1:00 through 1:59:59.99999.&=23160; &=23160;The Postgres date= ranges are the same way.&=23160; &=23160;The starting point is inclusive= , but the ending time is exclusive.&=23160; &=23160;So =5B1:00,2:00), and= =5B2:00,3:00), do not overlap.

On =46ri, Oct 15, 2021 at= 2:16 PM Ron <ronljohnsonjr=40gmail.com> wrote:
On 10/15/21= 8:59 AM, Adrian Klaver wrote:
> On 10/15/21 06:52, Ron wrote:
>> On 10/14/21 7:02 PM, Adrian Klaver wrote:
>> =5Bsnip=5D
>>> or the third example in the docs:
>>>
>>> SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS
= >>> &=23160;&=23160;&=23160;&=23160;&=23160;&=23160; (DATE '2001= -10-30', DATE '2002-10-30');
>>> Result: true
>>> SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS
>>> &=23160;&=23160;&=23160;&=23160;&=23160;&=23160; (DATE '2001= -10-30', DATE '2002-10-30');
>>> Result: false
>>> SELECT (DATE '2001-10-29', DATE '2001-10-30') OVERLAPS
= >>> &=23160;&=23160;&=23160;&=23160;&=23160;&=23160; (DATE '2001= -10-30', DATE '2001-10-31');
>>> Result: false
>>
>> Why /don't/ they overlap, given that they share a common date=3F=
>
> Per the docs:
>
> https://www.po= stgresql.org/docs/current/functions-datetime.html
>
> =22 Each time period is considered to represent the half-open interv= al start
> <=3D time < end, unless start and end are equal in which case = it represents
> that single time instant.=22
>
> Which I read as
>
> (DATE '2001-10-29', DATE '2001-10-30') ends at '2001-10-29'
>
> and
>
> (DATE '2001-10-30', DATE '2001-10-31') starts at DATE '2001-10-30' >
> so no overlap.

I was afraid you were going to say that.&=23160; It's completely bizarre,= but seems
to be a =22thing=22 in computer science.

--
Angular momentum makes the world go 'round.


--6169d5f8_515f007c_24a--