Help with Weeknum() Function

how to make the weknum function only read in that month
example if i put a [date] column are 10/2/2021 then the weeknum is 1 not 40

Solved Solved
0 5 186
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Try this:

SWITCH(
  EOWEEK([date]),
  EOWEEK(EOMONTH([date], -1) + 1),
    1,
  EOWEEK(EOMONTH([date], -1) + 1 + 7),
    2,
  EOWEEK(EOMONTH([date], -1) + 1 + 14),
    3,
  EOWEEK(EOMONTH([date], -1) + 1 + 21),
    4,
  5
)

View solution in original post

5 REPLIES 5

Steve
Platinum 4
Platinum 4

So you want the week number of the month rather than of the year?

yes correct

Would this be the case of finding the weeknum of the 1st day of the same month and then subtracting the two?

Steve
Platinum 4
Platinum 4

Try this:

SWITCH(
  EOWEEK([date]),
  EOWEEK(EOMONTH([date], -1) + 1),
    1,
  EOWEEK(EOMONTH([date], -1) + 1 + 7),
    2,
  EOWEEK(EOMONTH([date], -1) + 1 + 14),
    3,
  EOWEEK(EOMONTH([date], -1) + 1 + 21),
    4,
  5
)

it works. Thanks a lot

Top Labels in this Space