用vbs代码计算当月天数,例如"2008-02-11"的当月天数是29

2026年09月23日 06:11
有1个网友回答
网友(1):

Function days(s)
On Error Resume Next
mdate = DateValue(s)
If Err Then      '输入的日期错误,则返回0
    days = 0
    Exit Function
End If
yy = Year(mdate)
mm = Month(mdate)
date1 = DateSerial(yy, mm, 1)
date2 = DateSerial(yy, mm + 1, 1)
days = DateDiff("d", date1, date2)
End Function