Date.WeekOfMonth
Which week of its month a date falls in, counting the week that holds the 1st as week 1.
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Date.WeekOfMonth(dateTime as any, optional firstDayOfWeek as nullable number) as nullable number
| Parameter | Type | Description |
|---|---|---|
dateTime | any | A date, datetime or datetimezone value; null gives null. |
firstDayOfWeek | nullable number optional | The day a week starts on: Day.Sunday (0) to Day.Saturday (6). Left out or null, the culture's first day is used. |
Returns
nullable number. 1 to 6.
Remarks
- With no first day given, the week starts on the first day of the query's culture: Sunday in en-US, Monday in Norway, Britain and Germany (nb-NO, en-GB, de-DE). Give
Day.Monday(or another day) when the answer must not depend on the culture. - Week 1 may be short: it runs from the 1st to the first week's last day. A month can touch six weeks.
Examples
The last day of March 2024, weeks from Sunday
Date.WeekOfMonth(#date(2024, 3, 31))
6
1 March 2024 was a Friday, so week 1 holds only the 1st and the 2nd; the 31st, a Sunday, opens week 6.
The same day, weeks from Monday
Date.WeekOfMonth(#date(2024, 3, 31), Day.Monday)
5