Re: overlaps() does not work as expected? - Mailing list pgsql-hackers

From Jochem van Dieten
Subject Re: overlaps() does not work as expected?
Date
Msg-id f96a9b830505271128493412f2@mail.gmail.com
Whole thread Raw
In response to overlaps() does not work as expected?  (Mario Weilguni <mweilguni@sime.com>)
List pgsql-hackers
On 5/27/05, Mario Weilguni wrote:
> I've quite some trouble with the overlaps function:
> SELECT overlaps('9.6.2005'::date, '9.6.2005'::date, '9.6.2005'::date,
> '9.6.2005'::date);
> returns true (these are german timestamps dd.mm.yyyy)
>
> SELECT overlaps('8.6.2005'::date, '9.6.2005'::date, '9.6.2005'::date,
> '9.6.2005'::date);
> returns false
>
> Is this a bug or a (quite strange) feature?

It is consistent with the SQL standard:
<quote>
<overlaps predicate> uses the operator OVERLAPS to determine whether
or not two chronological periods overlap in time. A chronological
period is specified aither as a pair of datetimes (starting and
ending) or as a starting datetime and an interval. If the length of
the period is greater than 0 (zero), then the period consists of all
points of time greater than or equal to the lower endpoint, and less
than the upper endpoint. If the length of the period is equal to 0
(zero), then the period consists of a single point in time, the lower
endpoint. Two periods overlap if they have at least one point in
common.
</quote> ISO/IEC 9075-2:2003 4.6 Datetimes and intervals.

For those who prefer BNF look at 8.13 <overlaps predicate> in said standard.

Jochem


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: overlaps() does not work as expected?
Next
From: Josh Berkus
Date:
Subject: OSCON field trip, Friday afternoon