Date.Month

Date

Returns the month 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.Month(dateTime as any) as nullable number

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date value to extract the month from.

Return Value

numberThe month component of the date (1 through 12).

Remarks

Date.Month returns the month component as a number from 1 (January) to 12 (December) from a date, datetime, or datetimezone value. If the input is null, the function returns null.

Examples

Example 1: Extract the month from OrderDate

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

Example 2: Group Sales by month

Table.Group(
    Sales,
    {"OrderDate"},
    {{"OrderCount", each Table.RowCount(_), Int64.Type}},
    GroupKind.Local,
    (a, b) => Byte.From(Date.Month(a[OrderDate]) <> Date.Month(b[OrderDate]))
)
Result
OrderDate
OrderCount
11/15/20242
22/1/20242
33/5/20242
44/1/20242

Compatibility

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