Math 如何计算一个月内的周数,给定sunsat是周数

Math 如何计算一个月内的周数,给定sunsat是周数,math,logic,date-arithmetic,Math,Logic,Date Arithmetic,假设我的一周从周日开始,到周六结束 给定一个日期,我想在那个月找到周数,但也要考虑几个星期。例如,在本日历中 19年1月1日:第1周 19年1月6日:第2周 19年1月26日:第4周 19年1月28日:第5周 19年2月1日:第1周 19年2月28日:第5周 19年6月1日:第1周 19年6月30日:第6周 谢谢 我解决了 Month1stSunday = 8-Date.DayOfWeek(Date.StartOfMonth([FieldDate]), Day.Sunday) if (Date

假设我的一周从周日开始,到周六结束

给定一个日期,我想在那个月找到周数,但也要考虑几个星期。例如,在本日历中

19年1月1日:第1周
19年1月6日:第2周
19年1月26日:第4周
19年1月28日:第5周

19年2月1日:第1周
19年2月28日:第5周

19年6月1日:第1周
19年6月30日:第6周

谢谢

我解决了

Month1stSunday = 8-Date.DayOfWeek(Date.StartOfMonth([FieldDate]), Day.Sunday)

if (Date.Day([FieldDate]) <= [Month1stSunday]) then "W1" 
  else if (Date.Day([FieldDate]) <= [Month1stSunday]+7) then "W2" 
  else if (Date.Day([FieldDate]) <= [Month1stSunday]+14) then "W3" 
  else if (Date.Day([FieldDate]) <= [Month1stSunday]+21) then "W4" 
  else if (Date.Day([FieldDate]) > [Month1stSunday]+21) then "W5" 
else ""
Month1stSunday=8-Date.DayOfWeek(Date.StartOfMonth([FieldDate]),Day.Sunday)
如果(日期日期([FieldDate])