Date.EndOfWeek

Date.EndOfWeek is a Power Query M function that returns the end of the week, with an optional parameter to set the first day of the week. The function returns the end of the week as a date, datetime, or datetimezone value.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

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

Description

Returns the end of the week that contains dateTime. This function takes an optional DayfirstDayOfWeek, to set as the first day of the week for this relative calculation. The default value is Day.Sunday.

Examples

Get the end of the week for 5/14/2011.

// Output: #date( 2011, 5, 14 )
Date.EndOfWeek( #date( 2011, 5, 14 ) )

Get the end of the week for 5/17/2011 05:00:00 PM -7:00, with Sunday as the first day of the week.

// Output: #datetimezone( 2011, 5, 21, 23, 59, 59.9999999, -7, 0 )
Date.EndOfWeek( #datetimezone( 2011, 5, 17, 5, 0, 0, -7, 0 ), Day.Sunday )

Learn more about Date.EndOfWeek in the following articles:

Other functions related to Date.EndOfWeek are:

BI Gorilla Youtube Channel

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-endofweek
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.