OVERLAPS
Evaluates two time periods and returns true when they overlap, false otherwise.
Behavior Type
- Stable when
TIMESTAMP
andTIMESTAMPTZ
are both used, or whenTIMESTAMPTZ
is used withINTERVAL
- Immutable otherwise
Syntax
( start, end ) OVERLAPS ( start, end ) ( start, interval) OVERLAPS ( start, interval )
Parameters
start |
|
end |
|
interval |
Value that specifies the length of the time period. |
Examples
Evaluate whether date ranges Feb 16 - Dec 21, 2016 and Oct 10 2008 - Oct 3 2016 overlap:
=> SELECT (DATE '2016-02-16', DATE '2016-12-21') OVERLAPS (DATE '2008-10-30', DATE '2016-10-30'); overlaps ---------- t (1 row)
Evaluate whether date ranges Feb 16 - Dec 21, 2016 and Jan 01 - Oct 30 2008 - Oct 3, 2016 overlap:
=> SELECT (DATE '2016-02-16', DATE '2016-12-21') OVERLAPS (DATE '2008-01-30', DATE '2008-10-30'); overlaps ---------- f (1 row)
Evaluate whether date range Feb 02 2016 + 1 week overlaps with date range Oct 16 2016 - 8 months:
=> SELECT (DATE '2016-02-16', INTERVAL '1 week') OVERLAPS (DATE '2016-10-16', INTERVAL '-8 months'); overlaps ---------- t (1 row)