Date.EndOfWeek
The last day of the week a date falls in.
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Date.EndOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as any
| Parameter | Type | Description |
|---|---|---|
dateTime | any | A date, datetime or datetimezone value; null gives null. |
firstDayOfWeek | nullable number optional | The day a week starts on: Day.Sunday (0) to Day.Saturday (6). Left out or null, the culture's first day is used. |
Returns
any. The same kind of value, on the week's last day.
Remarks
- With no first day given, the week starts on the first day of the query's culture: Sunday in en-US, Monday in Norway, Britain and Germany (nb-NO, en-GB, de-DE). Give
Day.Monday(or another day) when the answer must not depend on the culture. - For a datetime or datetimezone the answer is the last moment of that day, 23:59:59.9999999; for a date it is the date.
Examples
The week of a Wednesday, en-US
Date.EndOfWeek(#date(2024, 3, 13))
#date(2024, 3, 16)
A week that starts on Sunday ends on Saturday: 16 March.
Weeks that start on Monday
Date.EndOfWeek(#date(2024, 3, 13), Day.Monday)
#date(2024, 3, 17)