---
title: "dateInterval(of:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/calendar/dateinterval(of:for:)"
---

# dateInterval(of:for:)

Returns the starting time and duration of a given calendar component that contains a given date.

## Declaration

```swift
func dateInterval(of component: Calendar.Component, for date: Date) -> DateInterval?
```

## Parameters

- `component`: A calendar component.
- `date`: The specified date.

## Return Value

Return Value A new DateInterval if the starting time and duration of a component could be calculated; otherwise, nil.

## See Also

### Calculating Intervals

- [dateInterval(of:start:interval:for:)](foundation/calendar/dateinterval(of:start:interval:for:).md)
- [dateIntervalOfWeekend(containing:)](foundation/calendar/dateintervalofweekend(containing:).md)
- [dateIntervalOfWeekend(containing:start:interval:)](foundation/calendar/dateintervalofweekend(containing:start:interval:).md)
- [nextWeekend(startingAfter:direction:)](foundation/calendar/nextweekend(startingafter:direction:).md)
- [nextWeekend(startingAfter:start:interval:direction:)](foundation/calendar/nextweekend(startingafter:start:interval:direction:).md)
- [Calendar.SearchDirection](foundation/calendar/searchdirection.md)
