Re: "two time periods with only an endpoint in common do not overlap" ??? - Mailing list pgsql-general

From Adrian Klaver
Subject Re: "two time periods with only an endpoint in common do not overlap" ???
Date
Msg-id e4c9e650-8361-8f8e-2357-e4919e2ed8d7@aklaver.com
Whole thread Raw
In response to Re: "two time periods with only an endpoint in common do not overlap" ???  (Ron <ronljohnsonjr@gmail.com>)
Responses Re: "two time periods with only an endpoint in common do not overlap" ???
List pgsql-general
On 10/15/21 19:42, Ron wrote:
> 
> 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.
> 

It is the programmers choice:

--The canonical form.
--No overlap
select int4range(1,3), int4range(3, 5);
  int4range | int4range
-----------+-----------
  [1,3)     | [3,5)

  select int4range(1,3) && int4range(3, 5);
  ?column?
----------
  f

--Making it overlap
select int4range(1,3, '[]'), int4range(3, 5, '[]');
  int4range | int4range
-----------+-----------
  [1,4)     | [3,6)

  select int4range(1,3, '[]') && int4range(3, 5, '[]');
  ?column?
----------
  t


There is no straight time range, you would have to use tsrange or 
tstzrange. The principle still holds though you can make ranges overlap 
or not depending on '[)' or '[]'.

-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: "two time periods with only an endpoint in common do not overlap" ???
Next
From: "David G. Johnston"
Date:
Subject: Re: "two time periods with only an endpoint in common do not overlap" ???