---
title: "predicateForEvents(withStart:end:calendars:)"
framework: eventkit
role: symbol
role_heading: Instance Method
path: "eventkit/ekeventstore/predicateforevents(withstart:end:calendars:)"
---

# predicateForEvents(withStart:end:calendars:)

Creates a predicate to identify events that occur within a given date range.

## Declaration

```swift
func predicateForEvents(withStart startDate: Date, end endDate: Date, calendars: [EKCalendar]?) -> NSPredicate
```

## Parameters

- `startDate`: The start date of the range of events fetched.
- `endDate`: The end date of the range of events fetched.
- `calendars`: An array of calendars to search, or nil to search all calendars.

## Mentioned in

Retrieving events and reminders

## Return Value

Return Value A predicate to use when calling enumerateEvents(matching:using:) or events(matching:).

## Discussion

Discussion Use this method to create a predicate for use with events(matching:) or enumerateEvents(matching:using:). The events returned using this predicate are in the default time zone. For performance reasons, this method matches only those events within a four-year time span. If the date range between startDate and endDate is greater than four years, it’s shortened to the first four years.

## See Also

### Searching calendars

- [enumerateEvents(matching:using:)](eventkit/ekeventstore/enumerateevents(matching:using:).md)
- [events(matching:)](eventkit/ekeventstore/events(matching:).md)
- [fetchReminders(matching:completion:)](eventkit/ekeventstore/fetchreminders(matching:completion:).md)
- [cancelFetchRequest(_:)](eventkit/ekeventstore/cancelfetchrequest(_:).md)
- [predicateForReminders(in:)](eventkit/ekeventstore/predicateforreminders(in:).md)
- [predicateForCompletedReminders(withCompletionDateStarting:ending:calendars:)](eventkit/ekeventstore/predicateforcompletedreminders(withcompletiondatestarting:ending:calendars:).md)
- [predicateForIncompleteReminders(withDueDateStarting:ending:calendars:)](eventkit/ekeventstore/predicateforincompletereminders(withduedatestarting:ending:calendars:).md)
- [EKEventSearchCallback](eventkit/ekeventsearchcallback.md)
