Date.WeekOfYear

Date.WeekOfYear is a Power Query M function that returns a number from 1 to 54 indicating which week of the year the date, dateTime, falls in. An optional firstDayOfWeek parameter can be specified.

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

Syntax

Date.WeekOfYear(
   dateTime as any,
   optional firstDayOfWeek as nullable number,
) as nullable number
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 a culture-dependent day, 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

Returns a number from 1 to 54 indicating which week of the year the date, dateTime, falls in.

  • dateTime: A datetime value for which the week-of-the-year is determined.
  • firstDayOfWeek: An optional Day.Type value that indicates which day is considered the start of a new week (for example, Day.Sunday). If unspecified, a culture-dependent default is used.

Examples

Determine which week of the year contains March 27th, 2011.

// Output: 14
Date.WeekOfYear( #date( 2011, 03, 27 ) )

Determine which week of the year contains March 27th, 2011, using Monday as the start of the week.

// Output: 13
Date.WeekOfYear( #date( 2011, 03, 27 ), Day.Monday )

Learn more about Date.WeekOfYear in the following articles:

Other functions related to Date.WeekOfYear 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-weekofyear
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.