Function GetWeekNo(InputDate)
dim pytY,pytNewYear,pytNewYearWeek,pytAllDay,pytBanWeek,NumWeek
NumWeek = 0
pytY = Year(InputDate)
pytNewYear=pytY &"-1-1"
pytNewYearWeek = Weekday(pytNewYear)
pytAllDay = DateDiff("d",pytNewYear,InputDate)
pytBanWeek = 8-pytNewYearWeek
if pytBanWeek<7 Then
NumWeek = 1
pytAllDay = pytAllDay - pytBanWeek
end if
tempx = pytAllDay/7
tempx = -Int(-tempx)
NumWeek = NumWeek+tempx
GetWeekNo = NumWeek
end Function
weekno=left(formatDateTime(now(),2),4)&GetWeekNo(now())
如果工厂周期与国际不一致,需要手动的查找判断进行-1.