Options

Check if a Date Range Overlaps another Date Range

Jim Knicely authored this tip.

The OVERLAPS Vertica built-in function evaluates two time periods and returns true when they overlap, false otherwise.

Example:

dbadmin=> SELECT (DATE '2018-04-18', DATE '2018-04-21') OVERLAPS (DATE '2018-04-16', DATE '2018-04-19');
 overlaps
----------
t
(1 row)

dbadmin=> SELECT (DATE '2018-04-18', DATE '2018-04-21') OVERLAPS (DATE '2018-04-22', DATE '2018-04-25');
 overlaps
----------
f
(1 row)

Have Fun!

Sign In or Register to comment.