<!--
{
  "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/HKWorkout/duration",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKWorkout(py)duration"
  },
  "title" : "duration"
}
-->

# duration

The workout’s duration.

```
var duration: TimeInterval { get }
```

## Discussion

A workout’s duration can be specified in one of three ways. The [`init(activityType:start:end:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:)) method uses the time interval between the provided start and end dates. The [`init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)) method sets the duration to the provided value. And the [`init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)`](/documentation/HealthKit/HKWorkout/init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)) method calculates the total active duration based on the start and end dates and the workout events.

---

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)