<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKSampleType/maximumAllowedDuration",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKSampleType(py)maximumAllowedDuration"
  },
  "title" : "maximumAllowedDuration"
}
-->

# maximumAllowedDuration

The maximum duration if the sample type has a restricted duration.

```
var maximumAllowedDuration: TimeInterval { get }
```

## Return Value

The maximum time interval between the sample’s [`startDate`](/documentation/HealthKit/HKSample/startDate) and [`endDate`](/documentation/HealthKit/HKSample/endDate) properties.

## Discussion

This method throws an exception if [`isMaximumDurationRestricted`](/documentation/HealthKit/HKSampleType/isMaximumDurationRestricted) is <doc://com.apple.documentation/documentation/Swift/false>.

---

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)