Ruzsinszky Attila <ruzsinszky.attila@gmail.com> writes:
> select (date '2009-08-23', date '2009-08-31') overlaps (date
> '2009-08-31', date '2009-08-31');
> I want testing whether a given date is in an interval.
> Why did I get false?
The SQL spec says that an exact match on ending endpoint isn't an overlap.
In particular, SQL92 defines the result of OVERLAPS as
( S1 > S2 AND NOT ( S1 >= T2 AND T1 >= T2 ) )
OR
( S2 > S1 AND NOT ( S2 >= T1 AND T2 >= T1 ) )
OR
( S1 = S2 AND ( T1 <> T2 OR T1 = T2 ) )
where S1,T1 are the smaller and larger endpoints of the first interval
and similarly for S2,T2. You've got S2 > S1, so the middle line
applies, but S2 = T1 and T2 = T1 so the result is false.
regards, tom lane