Re: "two time periods with only an endpoint in common do not overlap" ???

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: "two time periods with only an endpoint in common do not overlap" ???
Date: 2021-10-16 02:42:36
Message-ID: 6f61f1d3-c110-e6dd-d742-1bb45fb6e90e@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


The numeric ranges 0-10 and 10-19 overlap, just as the time ranges
00:01:00-00:00:02:00 overlaps 00:02:00-00:03:00.

*It's the programmer's responsibility* to say what s/he really means, not
for "the system" to make that choice.

On 10/15/21 1:27 PM, Brian Dunavant 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(at)gmail(dot)com
> <mailto:ronljohnsonjr(at)gmail(dot)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
> <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.
>
>

--
Angular momentum makes the world go 'round.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2021-10-16 04:08:30 Re: "two time periods with only an endpoint in common do not overlap" ???
Previous Message Adrian Klaver 2021-10-15 20:01:11 Re: "two time periods with only an endpoint in common do not overlap" ???