|
求某月的最后一天,我觉得这样更完美。
这是我的原创代码。- Public Function MonLastDay(dFirst As Date) As Date
- Dim dm As Date
- Dim m As Integer
-
- dm = dFirst
- m = Month(dm)
- Do While Month(dm) = m
- dm = dm + 1
- Loop
- MonLastDay = dm - 1
- End Function
复制代码 AlexLiu- Public Function MonLastDay1(dFirst As Date) As Date
- MonLastDay1 = DateSerial(Year(dFirst), Month(dFirst) + 1, 1) - 1
- End Function
复制代码 李啸林- Public Function MonLastDay1(dFirst As Date) As Date
- MonLastDay1 = DateAdd("d", -1, CDate(DatePart("yyyy", DateAdd("m", 1, dFirst)) & "-" & DatePart("m", DateAdd("m", 1, dFirst))))
- End Function
复制代码 |
|