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
Argument | Attribute | Description |
---|---|---|
dateTime | A date, datetime or datetimezone value. | |
firstDayOfWeek | optional | The 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
: Adatetime
value for which the week-of-the-year is determined.firstDayOfWeek
: An optionalDay.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 )
Related articles
Learn more about Date.WeekOfYear in the following articles:
- Create Date Table or Calendar in Power Query M
Learn how to create a dynamic calendar table in Power Query’s M language. Build your custom columns and claim your free Date Table Script. » Read more
Related functions
Other functions related to Date.WeekOfYear are:
- Date.Day
- Date.DayOfWeek
- Date.DayOfYear
- Date.DaysInMonth
- Date.Month
- Date.QuarterOfYear
- Date.WeekOfMonth
- Date.Year
