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