计算当前日期是任意时间段内第几周的函数
Function CalculateWeekNo(BeginDate,EndDate,InputDate)
dim wdate(500,8)
z=0
x=0
strlong=len(CStr(inputdate))-9
inputdate=cdate(left(CStr(inputdate),strlong))
for i=cdate(BeginDate) to cdate(EndDate)
if inputdate=i then
x=z
Exit For
end if
if weekday(i)=7 then
z=z+1
end if
next
CalculateWeekNo=x
end Function
博客提供了一个计算当前日期是任意时间段内第几周的函数。该函数接收开始日期、结束日期和输入日期作为参数,通过循环遍历时间段,根据每周的最后一天(周六)来确定周数,最终返回输入日期所在的周数。
4万+

被折叠的 条评论
为什么被折叠?



