简体   繁体   English

如何让 weeknum 从特定日期开始计算为第 1 周

[英]How do I get weeknum to start counting from a specific date as week 1

Im trying to automate a calendar for a maintenance schedule.我试图为维护计划自动化日历。

=IF(E$3>=$D5;IF(MOD(E$1-WEEKNUM($D5);INDEX($BG$5:$BG$11;MATCH($C5;$BE$5:$BE$11;0)))=0;$C5;"");"")

is the formula i have in the cells starting from E5 to the end of the year.是我从 E5 到年底的单元格中的公式。 The numbers in row 1 are the weeknumbers of row 3, and you can see the legend for the frequency table which is housed in be5 to bg11.第 1 行的数字是第 3 行的周数,您可以看到位于 be5 到 bg11 中的频率表的图例。 The problem I'm having is that sometimes the MOD returns 0 before sufficient time has passed leading to situations where the next scheduled maintenance appears to be too soon.我遇到的问题是,有时 MOD 在足够的时间过去之前返回 0,导致下一次定期维护似乎过早的情况。 I rationalize that if I can stipulate that the date of the last performed maintenance is weeknum 1, then I can make it work.我合理化,如果我可以规定上次执行维护的日期是第 1 周,那么我可以让它工作。 If theres another way I'm not seeing please point it out.如果theres另一种方式我没有看到请指出。

https://imgur.com/a/M4d8KZW https://imgur.com/a/M4d8KZW

there is a screenshot of what I have currently有我目前拥有的截图

Figured it out, at least for my specific issue.想通了,至少对于我的具体问题。

=IF(E$3>=$D5;IF(AND(MOD(E$1-WEEKNUM($D5)+INDEX($BG$5:$BG$20;MATCH($C5;$BE$5:$BE$20;0));INDEX($BG$5:$BG$20;MATCH($C5;$BE$5:$BE$20;0)))=0;WEEKNUM($D5)+INDEX($BG$5:$BG$20;MATCH($C5;$BE$5:$BE$20;0))<=E$1);$C5;"");"")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM