How to determine if a date range occurs any time within another date range?

前端 未结 5 1620
星月不相逢
星月不相逢 2021-02-02 04:07

I have an Event table that specifies a date range with start_date and end_date fields. I have another date range, specified in code, that defines the

5条回答
  •  别那么骄傲
    2021-02-02 04:53

    +1 for pop Catalin, but alas I have no voting privilege.

    The restrict condition you want is just the standard way to express Allen's "OVERLAPS" operator.

    Additional SQL caveat : if end_date is nullable, be sure to treat nulls in those columns as "the end of time".

    Additional functional caveat : be sure to adapt the usage of '<=' versus '<' to whether or not the recorded time periods include the end date or not.

提交回复
热议问题