Date.AddMonths
DateAdds a specified number of months to a date value.
Syntax
Date.AddMonths(dateTime as any, numberOfMonths as number) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The date, datetime, or datetimezone value to add months to. |
numberOfMonths | number | Yes | The number of months to add. Use negative values to subtract months. |
Return Value
any — The 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 | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 4/15/2024 |
| 2 | 2 | 1/18/2024 | 4/18/2024 |
| 3 | 3 | 2/1/2024 | 5/1/2024 |
| 4 | 4 | 2/10/2024 | 5/10/2024 |
| 5 | 5 | 3/5/2024 | 6/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 | |
|---|---|---|
| 1 | 3/31/2024 | 2/29/2024 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks