Date.DayOfYear

Date

Returns the day of the year (1–366) for the given date.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.DayOfYear(dateTime as any) as nullable number

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.

Return Value

numberAn integer from 1 to 366 representing the day of the year.

Remarks

Date.DayOfYear returns an integer from 1 (January 1) to 365 or 366 (December 31, depending on leap year) for a date, datetime, or datetimezone value. This is useful for cross-year comparisons where you want to compare progress through the year without regard to the specific year — for example, to find the same-day-of-year sales across multiple years. If the input is null, the function returns null.

Note that the maximum value is 365 in a common year and 366 in a leap year. When comparing day-of-year values across years, be aware that day 366 only exists in leap years. For these same-period comparisons, also consider using Date.Month + Date.Day directly to avoid the leap year edge case.

Date.DayOfYear is a simple ordinal counter with no locale or timezone sensitivity. It is not related to ISO week numbering; for ISO week numbers use Date.WeekOfYear with Day.Monday.

Examples

Example 1: Add day-of-year number to Sales table

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "DayOfYear", each Date.DayOfYear([OrderDate]), Int64.Type
)
Result
OrderID
OrderDate
DayOfYear
111/15/202415
221/18/202418
332/1/202432
442/10/202441
553/5/202465

Example 2: Day of year for a specific date

#table(
    type table [Date = date, DayOfYear = number],
    {{#date(2024, 3, 15), Date.DayOfYear(#date(2024, 3, 15))}}
)
Result
Date
DayOfYear
13/15/202475

Example 3: Filter rows to same day-of-year across all years

Table.SelectRows(
    Table.AddColumn(Sales, "DayOfYear", each Date.DayOfYear([OrderDate]), Int64.Type),
    each [DayOfYear] = 65
)
Result
OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
DayOfYear
15DianaWidget AWidgets2563/5/2024West65

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks