Date.Year

Date

Returns the year from a date value.

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

Syntax

Date.Year(dateTime as any) as nullable number

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date value to extract the year from.

Return Value

numberThe year component of the date.

Remarks

Date.Year returns the year component as a whole number from a date, datetime, or datetimezone value. If the input is null, the function returns null.

Examples

Example 1: Extract the year from OrderDate

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "Year", each Date.Year([OrderDate]), Int64.Type
)
Result
OrderID
OrderDate
Year
111/15/20242,024
221/18/20242,024
332/1/20242,024
442/10/20242,024
553/5/20242,024

Example 2: Extract the year from a scalar value

#table(
    type table [Date = date, Year = number],
    {{#date(2024, 3, 5), Date.Year(#date(2024, 3, 5))}}
)
Result
Date
Year
13/5/20242,024

Compatibility

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