OVERLAPS is a Standard SQL boolean operator that compares two date- or timestamp-based periods and evaluates to TRUE when the periods share at least one point in time. Each period is supplied as a row value of two temporal expressions: a start and an end. If a start value is later than its end, the values are automatically swapped before comparison, so the operator is order-agnostic. Boundaries are inclusive: an end instant equal to the other period’s start counts as an overlap. OVERLAPS is evaluated per row, making it useful in WHERE clauses and JOIN conditions for detecting scheduling conflicts, room or resource bookings, and temporal joins. The operator is deterministic and runs in O(1) time per row, but its availability is limited to dialects that implement the SQL standard feature F641.
- start1 TIMESTAMP/DATE
- first period start value- end1
(TIMESTAMP/DATE) - first period end value- start2 TIMESTAMP/DATE
- second period start value- end2
(TIMESTAMP/DATE) - second period end valueBETWEEN, RANGE types, temporal joins, LEAD/LAG, DATE_DIFF
SQL:1992 standard; first widely implemented in PostgreSQL 7.3
It returns a boolean value: TRUE if the two supplied periods intersect, otherwise FALSE.
No. If a period is supplied with the end earlier than the start, the database engine swaps them internally before performing the comparison.
Yes. If one period ends exactly when the other begins, OVERLAPS counts this as an overlap.
Use explicit comparisons: `(start1 <= end2) AND (end1 >= start2)`. Make sure to handle inclusive boundaries consistently.