pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guyren Howe <guyren@gmail.com>
To: Ron <ronljohnsonjr@gmail.com>
To: Brian Dunavant <dunavant@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: "two time periods with only an endpoint in common do not overlap" ???
Date: Fri, 15 Oct 2021 12:26:42 -0700
Message-ID: <bf07115a-0404-498a-ab7c-da1df62adf17@Spark> (raw)
In-Reply-To: <CAJ2+uGWsa0kZH2zvfBADMo=qy9UJC4aMuHLgQyVHMZyGFx==QQ@mail.gmail.com>
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>
	<d496d507-8abd-7e11-8e82-0f2983641803@gmail.com>
	<CAJ2+uGWsa0kZH2zvfBADMo=qy9UJC4aMuHLgQyVHMZyGFx==QQ@mail.gmail.com>

I’m a bit confused by this conversation. Open- and closed-ended ranges behave as I would expect.

select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '[)') && tsrange('2016-01-11 17:00', '2016-01-12 17:00', '[]')
false

select tsrange('2016-01-10 17:00', '2016-01-11 17:00', '[]') && tsrange('2016-01-11 17:00', '2016-01-12 17:00', '[]')
true
On Oct 15, 2021, 11:27 -0700, Brian Dunavant <dunavant@gmail.com>, wrote:
> Think of it this way.  When someone says they have a meeting from 1-2 and another from 2-3, do those meetings overlap?  They do not, because we're actually saying the first meeting is from 1:00 through 1:59:59.99999.   The Postgres date ranges are the same way.   The starting point is inclusive, but the ending time is exclusive.   So [1:00,2:00), and [2:00,3:00), do not overlap.
>
> > On Fri, Oct 15, 2021 at 2:16 PM Ron <ronljohnsonjr@gmail.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:
> > > >> [snip]
> > > >>> or the third example in the docs:
> > > >>>
> > > >>> SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS
> > > >>>        (DATE '2001-10-30', DATE '2002-10-30');
> > > >>> Result: true
> > > >>> SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS
> > > >>>        (DATE '2001-10-30', DATE '2002-10-30');
> > > >>> Result: false
> > > >>> SELECT (DATE '2001-10-29', DATE '2001-10-30') OVERLAPS
> > > >>>        (DATE '2001-10-30', DATE '2001-10-31');
> > > >>> Result: false
> > > >>
> > > >> Why /don't/ they overlap, given that they share a common date?
> > > >
> > > > Per the docs:
> > > >
> > > > https://www.postgresql.org/docs/current/functions-datetime.html
> > > >
> > > > " Each time period is considered to represent the half-open interval start
> > > > <= time < end, unless start and end are equal in which case it represents
> > > > that single time instant."
> > > >
> > > > 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.  It's completely bizarre, but seems
> > > to be a "thing" in computer science.
> > >
> > > --
> > > Angular momentum makes the world go 'round.
> > >
> > >

view thread (24+ messages)  latest in thread

Message-ID: <bf07115a-0404-498a-ab7c-da1df62adf17@Spark>
Permalink:  ../bf07115a-0404-498a-ab7c-da1df62adf17@Spark/
Also on:    postgresql.org/message-id/bf07115a-0404-498a-ab7c-da1df62adf17@Spark

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guyren@gmail.com, ronljohnsonjr@gmail.com, dunavant@gmail.com
  Subject: Re: "two time periods with only an endpoint in common do not overlap" ???
  In-Reply-To: <bf07115a-0404-498a-ab7c-da1df62adf17@Spark>
  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> <d496d507-8abd-7e11-8e82-0f2983641803@gmail.com> <CAJ2+uGWsa0kZH2zvfBADMo=qy9UJC4aMuHLgQyVHMZyGFx==QQ@mail.gmail.com> <bf07115a-0404-498a-ab7c-da1df62adf17@Spark>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox