Date.AddMonths

Date

Adds a specified number of months to 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.AddMonths(dateTime as any, numberOfMonths as number) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date, datetime, or datetimezone value to add months to.
numberOfMonthsnumberYesThe number of months to add. Use negative values to subtract months.

Return Value

anyThe date resulting from adding the specified number of months to the input date.

Remarks

Date.AddMonths adds or subtracts a whole number of months from a date, datetime, or datetimezone value. If the resulting day would exceed the number of days in the target month, the day is clamped to the last day of that month (e.g., adding 1 month to January 31 yields February 28 or 29).

Examples

Example 1: Add 3 months to each OrderDate

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "Plus3Months", each Date.AddMonths([OrderDate], 3), type date
)
Result
OrderID
OrderDate
Plus3Months
111/15/20244/15/2024
221/18/20244/18/2024
332/1/20245/1/2024
442/10/20245/10/2024
553/5/20246/5/2024

Example 2: Subtract 1 month from a date

#table(
    type table [OriginalDate = date, PreviousMonth = date],
    {{#date(2024, 3, 31), Date.AddMonths(#date(2024, 3, 31), -1)}}
)
Result
OriginalDate
PreviousMonth
13/31/20242/29/2024

Compatibility

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