---
title: "isDate(_:equalTo:toUnitGranularity:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscalendar/isdate(_:equalto:tounitgranularity:)"
---

# isDate(_:equalTo:toUnitGranularity:)

Indicates whether two dates are equal to a given unit of granularity.

## Declaration

```swift
func isDate(_ date1: Date, equalTo date2: Date, toUnitGranularity unit: NSCalendar.Unit) -> Bool
```

## Parameters

- `date1`: The first date to compare.
- `date2`: The second date to compare.
- `unit`: The smallest unit that must, along with all larger units, be equal in the given dates. For possible values, see doc://com.apple.foundation/documentation/Foundation/NSCalendar/Unit.

## Return Value

Return Value true if both dates have equal date component for all units greater than or equal to the given unit, otherwise false.

## See Also

### Comparing Dates

- [compare(_:to:toUnitGranularity:)](foundation/nscalendar/compare(_:to:tounitgranularity:).md)
- [isDate(_:inSameDayAs:)](foundation/nscalendar/isdate(_:insamedayas:).md)
- [isDateInToday(_:)](foundation/nscalendar/isdateintoday(_:).md)
- [isDateInTomorrow(_:)](foundation/nscalendar/isdateintomorrow(_:).md)
- [isDateInWeekend(_:)](foundation/nscalendar/isdateinweekend(_:).md)
- [isDateInYesterday(_:)](foundation/nscalendar/isdateinyesterday(_:).md)
