Date.StartOfWeek

Updated on

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
ArgumentAttributeDescription
dateTimeA date, datetime or datetimezone value.
firstDayOfWeekoptionalThe Day.Type specifies the starting day of the week. If not explicitly specified, the function defaults to Day.Sunday, aligning with regional week-start norms. It accepts values representing each day:
Day.Sunday (0) for Sunday,
Day.Monday (1) for Monday,
Day.Tuesday (2) for Tuesday,
Day.Wednesday (3) for Wednesday,
Day.Thursday (4) for Thursday,
Day.Friday (5) for Friday,
Day.Saturday (6) for Saturday.

Description

Date.StartOfWeek returns the start date of the week that contains the given date, datetime, or datetimezone value (dateTime). You can provide an optional firstDayOfWeek, to indicate which day is considered the firs tday of the week. By defaul tthe function uses 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

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-startofweek