场景:尝试使用给定时间段找出结束周数(当年的周数)和开始周数。假设PeriodWeeks = 10。这意味着从今天的周数到过去 10 周,在当前情况下肯定会到去年。
我有的代码:
perdiodWeeks = 10 ' this is a constant in the code
periodMonths= periodQtrs * 3 ' this calculates month from given number of quarters
endDate = DateAdd("m",-1,Date)
endYear = DatePart("yyyy", endDate)
endMonth = DatePart("m", endDate)
startDate = DateAdd("m", -(periodMonths-1), endDate)
startYear = DatePart("yyyy", startDate)
startMonth = DatePart("m", startDate)
如何计算以下内容?
startYW ' start year week number
endYW ' end year week number
其中值将是endYW = 201506 和startYW = 来自 endYW 的 perdiodWeeks。06 是 2015 年的当前周数