<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Calendar/isDate(_:equalTo:toGranularity:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation8CalendarV6isDate_7equalTo13toGranularitySbAA0D0V_AhC9ComponentOtF"
  },
  "title" : "isDate(_:equalTo:toGranularity:)"
}
-->

# isDate(_:equalTo:toGranularity:)

Returns a Boolean value indicating whether two dates are equal down to the specified component.

```
func isDate(_ date1: Date, equalTo date2: Date, toGranularity component: Calendar.Component) -> Bool
```

## Parameters

`date1`

A date to compare.

`date2`

A date to compare.

`component`

A granularity to compare. For example, pass `.hour` to check if two dates are in the same hour.

## Return Value

`true` if the two dates are equal in the given component and all larger components; otherwise, `false`.

## Discussion

---

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)