<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuery/predicateForWorkoutActivities(start:end:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForWorkoutActivitiesWithStartDate:endDate:options:"
  },
  "title" : "predicateForWorkoutActivities(start:end:options:)"
}
-->

# predicateForWorkoutActivities(start:end:options:)

Returns a predicate for workout activities that occur between the start and end date.

```
class func predicateForWorkoutActivities(start startDate: Date?, end endDate: Date?, options: HKQueryOptions = []) -> NSPredicate
```

## Parameters

`startDate`

The start date for the target time interval.

`endDate`

The end date for the target time interval.

`options`

A constant that specifies how HealthKit compares the sample’s start and end date with the target time interval. For a list of possible values, see [`HKQueryOptions`](/documentation/HealthKit/HKQueryOptions).

## Discussion

Use this convenience method to create a predicate that matches workout activities that occur between the specified start and end dates. To use this predicate, call [`predicateForWorkouts(activityPredicate:)`](/documentation/HealthKit/HKQuery/predicateForWorkouts(activityPredicate:)) to wrap this predicate inside a workout predicate. You can then use the workout predicate in your query.

The following sample creates a predicate for workout activities within the last 30 minutes.

```swift
let end = Date()
let start = end.advanced(by: -30.0 * 60.0)

let recentActivityPredicate =
HKQuery.predicateForWorkoutActivities(start: start, end: end)

let workoutPredicate =
HKQuery.predicateForWorkouts(activityPredicate: recentActivityPredicate)
```

---

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)