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

# duration

The activity’s duration, measured in seconds.

## Declaration

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

## Discussion

Discussion HealthKit calculates the duration as the elapsed time between the activity’s startDate and endDate, ignoring any pause periods. If an activity is currently in progress, it has a nil-valued endDate. In this case, HealthKit calculates the duration as the time between the startDate and the current time, ignoring any pause periods.

## See Also

### Accessing workout data

- [uuid](healthkit/hkworkoutactivity/uuid.md)
- [startDate](healthkit/hkworkoutactivity/startdate.md)
- [endDate](healthkit/hkworkoutactivity/enddate.md)
- [allStatistics](healthkit/hkworkoutactivity/allstatistics.md)
- [statistics(for:)](healthkit/hkworkoutactivity/statistics(for:).md)
- [metadata](healthkit/hkworkoutactivity/metadata.md)
- [workoutConfiguration](healthkit/hkworkoutactivity/workoutconfiguration.md)
- [workoutEvents](healthkit/hkworkoutactivity/workoutevents.md)
