Date.AddWeeks
DateAdds a specified number of weeks to a date value.
Syntax
Date.AddWeeks(dateTime as any, numberOfWeeks as number) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The date, datetime, or datetimezone value to add weeks to. |
numberOfWeeks | number | Yes | The number of weeks to add. Use negative values to subtract weeks. |
Return Value
any — The date resulting from adding the specified number of weeks to the input value.
Remarks
Date.AddWeeks adds or subtracts a whole number of weeks (7-day periods) from a date, datetime, or datetimezone value. Date.AddWeeks(d, n) is equivalent to Date.AddDays(d, n * 7), but is more self-documenting when the intent is explicitly to shift by weeks. Passing a negative numberOfWeeks subtracts weeks. The return type matches the input type.
Unlike Date.AddMonths, week arithmetic is always exact: there is no end-of-month clamping to worry about, since every week is exactly 7 days regardless of the calendar month boundaries. This makes Date.AddWeeks safe to use in rolling window calculations.
Use Date.AddWeeks when your business logic is expressed in weeks — for example, a 2-week lead time, a 4-week rolling period, or a billing cycle measured in weeks. For day-precise shifts, use Date.AddDays directly.
Examples
Example 1: Add a 2-week lead time to each order date
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(Sales, 5),
{"OrderID", "OrderDate"}
),
"ShipByDate", each Date.AddWeeks([OrderDate], 2), type date
)OrderID | OrderDate | ShipByDate | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 1/29/2024 |
| 2 | 2 | 1/18/2024 | 2/1/2024 |
| 3 | 3 | 2/1/2024 | 2/15/2024 |
| 4 | 4 | 2/10/2024 | 2/24/2024 |
| 5 | 5 | 3/5/2024 | 3/19/2024 |
Example 2: Subtract one week from a date
#table(
type table [Today = date, LastWeek = date],
{{#date(2024, 3, 15), Date.AddWeeks(#date(2024, 3, 15), -1)}}
)Today | LastWeek | |
|---|---|---|
| 1 | 3/15/2024 | 3/8/2024 |
Example 3: Build a 4-week rolling window start date
Table.AddColumn(
Table.SelectColumns(
Table.FirstN(Sales, 5),
{"OrderID", "OrderDate"}
),
"WindowStart", each Date.AddWeeks([OrderDate], -4), type date
)OrderID | OrderDate | WindowStart | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 12/18/2023 |
| 2 | 2 | 1/18/2024 | 12/21/2023 |
| 3 | 3 | 2/1/2024 | 1/4/2024 |
| 4 | 4 | 2/10/2024 | 1/13/2024 |
| 5 | 5 | 3/5/2024 | 2/6/2024 |