---
title: interval
framework: foundation
role: symbol
role_heading: Type Property
path: foundation/formatstyle/interval
---

# interval

A style for formatting a date interval.

## Declaration

```swift
static var interval: Date.IntervalFormatStyle { get }
```

## Discussion

Discussion Use this type property when the call point allows the use of Date.IntervalFormatStyle. You typically do this when calling the formatted(_:) method of a Range<Date>. The folllowing example uses interval to create a date interval string with specific styling of the day, month, and weekday components, omitting the year and time. if let today = Calendar.current.date(byAdding: .day, value: -120, to: Date()),     let thirtyDaysBeforeToday = Calendar.current.date(byAdding: .day, value: -30, to: today) {     // today: June 5, 2023     // thirtyDaysBeforeToday: May 6, 2023

// Create a Range<Date>.     let last30days = thirtyDaysBeforeToday..<today

let formatted = last30days.formatted(         .interval         .day()         .month(.wide)         .weekday(.abbreviated)     ) // "Sat, May 6 – Mon, June 5" }

## See Also

### Applying date and time styles

- [dateTime](foundation/formatstyle/datetime.md)
- [Date.FormatStyle](foundation/date/formatstyle.md)
- [Date.ISO8601FormatStyle](foundation/date/iso8601formatstyle.md)
- [verbatim(_:locale:timeZone:calendar:)](foundation/formatstyle/verbatim(_:locale:timezone:calendar:).md)
- [Date.VerbatimFormatStyle](foundation/date/verbatimformatstyle.md)
- [Date.IntervalFormatStyle](foundation/date/intervalformatstyle.md)
- [relative(presentation:unitsStyle:)](foundation/formatstyle/relative(presentation:unitsstyle:).md)
- [Date.RelativeFormatStyle](foundation/date/relativeformatstyle.md)
- [components(style:fields:)](foundation/formatstyle/components(style:fields:).md)
- [Date.ComponentsFormatStyle](foundation/date/componentsformatstyle.md)
