---
title: Determine whether two date ranges overlap
summary: Test whether two date ranges intersect.
status: draft
owner: saif-docgen
last_reviewed: 2026-09-15
library: SAIF.Framework.Common
reference_type: package
operation_id: OP-003
trigger: Caller compares two `IDateRange` instances
---

# Determine whether two date ranges overlap

Test whether two date ranges intersect, triggered when caller compares two `IDateRange` instances.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-003 |
| **Trigger** | Caller compares two `IDateRange` instances |
| **Inputs** | `range1`, `range2`, `inAllowSameDateOverlap` |
| **Outputs** | `Boolean` |
| **Primary components** | ``DateRangeExtensions.IsOverlapping(this IDateRange, IDateRange, Boolean inAllowSameDateOverlap = false)`` |
| **Entry point** | `Common/SAIF.Common/Extensions/DateRangeExtensions.cs` |

## Steps

1. Translate `inAllowSameDateOverlap` into an `IncludeComparisons` mode: `true` → `Exclusive` (touching endpoints are not an overlap), `false` → `Inclusive`. ([BR-004](../business-rules.md#br-004-whether-shared-endpoints-count-as-an-overlap-is-caller-selectable))
2. Guard: proceed only if `range2` is non-null and both ranges pass `IsValidRange()`. Otherwise return `false`. ([BR-001](../business-rules.md#br-001-a-date-range-is-valid-only-when-begindate-is-less-than-or-equal-to-enddate), [BR-002](../business-rules.md#br-002-a-range-is-%22open-ended%22-when-begindate-is-datetime.minvalue-or-enddate-is-datetime.maxvalue))
3. Return `true` if any of four conditions hold: `range2.BeginDate` falls inside range1; `range2.EndDate` falls inside range1; `range1.BeginDate` falls inside range2; or the ranges are exactly identical and not zero-length. Membership is evaluated by `IComparableExtensions.IsBetween` using the mode from step 1. ([BR-003](../business-rules.md#br-003-two-ranges-with-identical-begin-and-end-dates-overlap-only-when-they-are-not-a-single-day), [BR-004](../business-rules.md#br-004-whether-shared-endpoints-count-as-an-overlap-is-caller-selectable))
4. Otherwise return `false`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([IsOverlapping called]) --> S1["Translate inAllowSameDateOverlap<br>into comparison mode"]
	S1 --> D1{"range2 non-null and<br>both ranges valid?"}
	D1 -->|No| R1([Return false])
	D1 -->|Yes| D2{"Any of 4 overlap<br>conditions true?"}
	D2 -->|Yes| R2([Return true])
	D2 -->|No| R3([Return false])
```

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `Common/SAIF.Common/Extensions/DateRangeExtensions.cs`
