<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDateInterval/intersection(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDateInterval(im)intersectionWithDateInterval:"
  },
  "title" : "intersection(with:)"
}
-->

# intersection(with:)

Returns the intersection between the receiver and the specified date interval.

```
func intersection(with dateInterval: DateInterval) -> DateInterval?
```

## Parameters

`dateInterval`

The date interval with which to calculate the intersection of the receiver.

## Return Value

A date interval for the intersection of the receiver and `dateInterval`, or `nil` if no intersection occurs.

## Discussion

Calculating the intersection of date intervals is a commutative and associative operation. The intersection of a date interval with itself is equal to itself.

The following figure illustrates five `NSDateInterval` objects plotted on an arbitrary time axis. Each date interval spans its [`duration`](/documentation/Foundation/NSDateInterval/duration) from left to right, from its [`startDate`](/documentation/Foundation/NSDateInterval/startDate) to its [`endDate`](/documentation/Foundation/NSDateInterval/endDate).

![](images/com.apple.foundation/media-2556958@2x.png)

The date intervals labeled **A** and **B** do not intersect, because the [`startDate`](/documentation/Foundation/NSDateInterval/startDate) of **B** occurs later than the [`endDate`](/documentation/Foundation/NSDateInterval/endDate) of **A**.

The date intervals  labeled **C** and **D** do intersect. The date interval labeled **E** represents the result of calculating the intersection between **C** and **D**.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)