---
title: duration
framework: healthkit
role: symbol
role_heading: Instance Property
path: healthkit/hkworkout/duration
---

# duration

The workout’s duration.

## Declaration

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

## Mentioned in

Adding samples to a workout

## Discussion

Discussion A workout’s duration can be specified in one of three ways. The 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:) method sets the duration to the provided value. And the 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.

## See Also

### Accessing workout data

- [workoutActivityType](healthkit/hkworkout/workoutactivitytype.md)
- [workoutActivities](healthkit/hkworkout/workoutactivities.md)
- [workoutEvents](healthkit/hkworkout/workoutevents.md)
- [statistics(for:)](healthkit/hkworkout/statistics(for:).md)
- [allStatistics](healthkit/hkworkout/allstatistics.md)
- [totalDistance](healthkit/hkworkout/totaldistance.md)
- [totalEnergyBurned](healthkit/hkworkout/totalenergyburned.md)
- [totalFlightsClimbed](healthkit/hkworkout/totalflightsclimbed.md)
- [totalSwimmingStrokeCount](healthkit/hkworkout/totalswimmingstrokecount.md)
