Date.EndOfWeek

Date

Returns the last day of the week containing the given date.

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

Syntax

Date.EndOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.
firstDayOfWeeknumberNoA Day.* constant specifying the first day of the week. Defaults to Day.Sunday (0). Use Day.Monday (1) for ISO weeks.

Return Value

anyA datetime or datetimezone representing the last instant of the week containing the input date.

Remarks

Date.EndOfWeek returns the last instant (23:59:59.9999999) of the calendar week containing the input value. By default, weeks start on Sunday (Day.Sunday = 0), making Saturday the last day of the week. Pass Day.Monday (1) to use ISO 8601-style Monday-to-Sunday weeks, where Sunday is the last day.

Always use the Day.* enum constants (e.g., Day.Monday, Day.Sunday) rather than integer literals when specifying firstDayOfWeek. This makes the intent explicit and avoids confusion, since 0 means Sunday while 1 means Monday.

The return type matches the input type: a plain date input produces a datetime result with the time component at 23:59:59.9999999; a datetimezone input preserves the timezone offset. Pair with Date.StartOfWeek to define an inclusive weekly range for filtering or grouping.

Examples

Example 1: Find the end of the week for each order date (Sunday start)

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "WeekEnd", each Date.EndOfWeek([OrderDate], Day.Sunday), type datetime
)
Result
OrderID
OrderDate
WeekEnd
111/15/20241/20/2024 11:59:59 PM
221/18/20241/20/2024 11:59:59 PM
332/1/20242/3/2024 11:59:59 PM
442/10/20242/10/2024 11:59:59 PM
553/5/20243/9/2024 11:59:59 PM

Example 2: End of ISO week (Monday start)

#table(
    type table [Date = date, ISOWeekEnd = datetime],
    {{#date(2024, 3, 13), Date.EndOfWeek(#date(2024, 3, 13), Day.Monday)}}
)
Result
Date
ISOWeekEnd
13/13/20243/17/2024 11:59:59 PM

Example 3: Group orders by their week ending date

Table.AddColumn(
    Table.SelectColumns(Sales, {"OrderID", "OrderDate", "UnitPrice", "Quantity"}),
    "WeekEndingDate",
    each Date.From(Date.EndOfWeek([OrderDate], Day.Monday)),
    type date
)
Result
OrderID
OrderDate
UnitPrice
Quantity
WeekEndingDate
111/15/20242541/21/2024
221/18/20245021/21/2024
332/1/202415102/4/2024
442/10/20247512/11/2024
553/5/20242563/10/2024
663/12/202412013/17/2024
774/1/20245034/7/2024
884/15/20241584/21/2024

Compatibility

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