OVERLAPS

The SQL OVERLAPS operator returns a Boolean value:
  • true when two time periods (defined by their endpoints) overlap
  • false when they do not overlap
(start1, end1) OVERLAPS (start2, end2)
(start1, interval1) OVERLAPS (start2, interval2)

You can specify the endpoints as pairs of dates, times, or timestamps. Alternatively, you can specify a date, time, or timestamp followed by an interval literal. When you specify a pair of values, the order does not matter; OVERLAPS automatically takes the earlier value of the pair as the start.

The following example specifies two pairs of date literals.
premdb=# select 
('17-May-2016'::date, '13-Oct-2016'::date) 
overlaps 
('1-jun-2016'::date, '1-jul-2016'::date) 
from sys.const;
 overlaps 
----------
 t
(1 row)
The following example specifies two pairs of time literals.
premdb=# select 
(time '12:00:00', time '13:00:00') 
overlaps 
(time '12:15:00', time '12:45:00') 
from sys.const;
 overlaps 
----------
 t
(1 row)
The following example specifies a pair of timestamp columns and a pair of timestamp literal values .
premdb=# select 
(min(matchday),max(matchday)) 
overlaps 
('09-September-1990'::timestamp, '09-September-2000'::timestamp) 
from match;
 overlaps 
----------
 t
(1 row)
In this example, one endpoint of each pair of arguments is an interval (a number of days in this case):
premdb=# select 
(min(matchday),interval '100 days') 
overlaps 
('09-September-1999'::timestamp,interval '100 days') 
from match;
 overlaps 
----------
 f
(1 row)