---
title: "predicateForWorkoutActivities(start:end:options:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkquery/predicateforworkoutactivities(start:end:options:)"
---

# predicateForWorkoutActivities(start:end:options:)

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

## Declaration

```swift
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 doc://com.apple.healthkit/documentation/HealthKit/HKQueryOptions.

## Discussion

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:) 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. 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)

## See Also

### Creating workout activity predicates

- [predicateForWorkoutActivities(workoutActivityType:)](healthkit/hkquery/predicateforworkoutactivities(workoutactivitytype:).md)
- [predicateForWorkoutActivities(operatorType:duration:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:duration:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:averageQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:averagequantity:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:maximumQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:maximumquantity:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:minimumQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:minimumquantity:).md)
- [predicateForWorkoutActivities(operatorType:quantityType:sumQuantity:)](healthkit/hkquery/predicateforworkoutactivities(operatortype:quantitytype:sumquantity:).md)
