---
title: "date(_:matchesComponents:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscalendar/date(_:matchescomponents:)"
---

# date(_:matchesComponents:)

Returns whether a given date matches all of the given date components.

## Declaration

```swift
func date(_ date: Date, matchesComponents components: DateComponents) -> Bool
```

## Parameters

- `date`: The date for which to perform the calculation.
- `components`: The date components to match.

## Return Value

Return Value true if the given date matches the given components, otherwise false.

## Discussion

Discussion This method is useful for determining whether dates calculated by methods like  nextDate(after:matching:value:options:) or enumerateDates(startingAfter:matching:options:using:) are exact, or required an adjustment due to a nonexistent time.

## See Also

### Related Documentation

- [nextDate(after:matching:value:options:)](foundation/nscalendar/nextdate(after:matching:value:options:).md)
- [enumerateDates(startingAfter:matching:options:using:)](foundation/nscalendar/enumeratedates(startingafter:matching:options:using:).md)

### Extracting Components

- [component(_:from:)](foundation/nscalendar/component(_:from:).md)
- [components(_:from:)](foundation/nscalendar/components(_:from:).md)
- [components(_:from:to:options:)](foundation/nscalendar/components(_:from:to:options:)-84y5w.md)
- [components(_:from:to:options:)](foundation/nscalendar/components(_:from:to:options:)-49lo8.md)
- [components(in:from:)](foundation/nscalendar/components(in:from:).md)
- [getEra(_:year:month:day:from:)](foundation/nscalendar/getera(_:year:month:day:from:).md)
- [getEra(_:yearForWeekOfYear:weekOfYear:weekday:from:)](foundation/nscalendar/getera(_:yearforweekofyear:weekofyear:weekday:from:).md)
- [getHour(_:minute:second:nanosecond:from:)](foundation/nscalendar/gethour(_:minute:second:nanosecond:from:).md)
