<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKStatisticsCollection/enumerateStatistics(from:to:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKStatisticsCollection(im)enumerateStatisticsFromDate:toDate:withBlock:"
  },
  "title" : "enumerateStatistics(from:to:with:)"
}
-->

# enumerateStatistics(from:to:with:)

Enumerates the statistics objects for all the time intervals from the start date until the end date.

```
func enumerateStatistics(from startDate: Date, to endDate: Date, with block: @escaping (HKStatistics, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

`startDate`

The start date for the calculation. The initial statistics come from the time interval that contains the start date.

`endDate`

The end date for the calculation. The final statistics come from the time interval that contains the end date.

`block`

A block that is called once for each time interval. This method passes the following parameters to the block:

- result: The [`HKStatistics`](/documentation/HealthKit/HKStatistics) object containing the statistical data for this time interval.
- stop: A reference to a Boolean value. The block can set the value to <doc://com.apple.documentation/documentation/Swift/true> to stop further processing of the collection. The stop argument is an out-only argument. Only set this Boolean to <doc://com.apple.documentation/documentation/Swift/true> within the block.

## Discussion

This method enumerates the statistics in chronological order. It calls the block once for each time interval between the start and end dates. If there are no samples for a particular time interval, the corresponding statistic object has a `nil`-valued quantity.

---

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)