---
title: "dayOfYear(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/date/formatstyle/dayofyear(_:)"
---

# dayOfYear(_:)

Modifies the date format style to use the specified day of the year format style.

## Declaration

```swift
func dayOfYear(_ format: Date.FormatStyle.Symbol.DayOfYear = .defaultDigits) -> Date.FormatStyle
```

## Parameters

- `format`: The day of the year format style applied to the date format style.

## Return Value

Return Value A date format style modified to include the specified day of the year style.

## Discussion

Discussion Values of Date.FormatStyle.Symbol.DayOfYear are defaultDigits, threeDigits, and twoDigits. This example shows a variety of Date.FormatStyle.Symbol.DayOfYear formats applied to a date: let meetingDate = Date() // Feb 9, 2021 at 3:00 PM meetingDate.formatted(Date.FormatStyle().dayOfYear(.defaultDigits)) // 40 meetingDate.formatted(Date.FormatStyle().dayOfYear(.twoDigits)) // 40 meetingDate.formatted(Date.FormatStyle().dayOfYear(.threeDigits)) // 040 meetingDate.formatted(Date.FormatStyle().dayOfYear()) // 40

If you don’t provide a format, the defaultDigits static variable is the default format. For more information about formatting dates, see Date.FormatStyle.

## See Also

### Specifying the Date Format

- [day(_:)](foundation/date/formatstyle/day(_:).md)
- [era(_:)](foundation/date/formatstyle/era(_:).md)
- [month(_:)](foundation/date/formatstyle/month(_:).md)
- [quarter(_:)](foundation/date/formatstyle/quarter(_:).md)
- [week(_:)](foundation/date/formatstyle/week(_:).md)
- [weekday(_:)](foundation/date/formatstyle/weekday(_:).md)
- [year(_:)](foundation/date/formatstyle/year(_:).md)
- [Date.FormatStyle.DateStyle](foundation/date/formatstyle/datestyle.md)
