Date.StartOfWeek

Date.StartOfWeek is a Power Query M function that returns the start of the week containing the specified date(Time). Your input must be a date, datetime, or datetimezone value.

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

Syntax

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

Description

Returns the start 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

Find the start of the week for Tuesday, October 11th, 2011.

Date.StartOfWeek( #datetime( 2011, 10, 11, 8, 10, 32 ) )

 /* Output: 
// Sunday, October 9th, 2011
#datetime( 2011, 10, 9, 0, 0, 0 )
 */ 

Find the start of the week for Tuesday, October 11th, 2011, using Monday as the start of the week.

Date.StartOfWeek( #datetime( 2011, 10, 11, 8, 10, 32 ), Day.Monday )

 /* Output: 
// Monday, October 10th, 2011
#datetime( 2011, 10, 10, 0, 0, 0 )
 */ 

Learn more about Date.StartOfWeek in the following articles:

Other functions related to Date.StartOfWeek are:

BI Gorilla Youtube Channel

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