|
3#
楼主 |
发表于 2004-6-26 02:13:00
|
只看该作者
'(闰年判断方法:闰年是能被4整除而不能被100整除的年份,或者是能被400整除的年份。闰年的2月份是29天)。
Function EndOfMonth(CurrentDate As Date)
Dim lngYear As Long
lngYear = Year(CurrentDate)
Select Case Month(CurrentDate)
Case 1
EndOfMonth = 31
Case 2
EndOfMonth = 28
If (lngYear / 4) - (lngYear \ 4) = 0 And (lngYear / 100) - (lngYear \ 100) <> 0 Then
EndOfMonth = 29
ElseIf (lngYear / 400) - (lngYear \ 400) = 0 Then
EndOfMonth = 29
End If
Case 3
EndOfMonth = 31
Case 4
EndOfMonth = 30
Case 5
EndOfMonth = 31
Case 6
EndOfMonth = 30
Case 7
EndOfMonth = 31
Case 8
EndOfMonth = 31
Case 9
EndOfMonth = 30
Case 10
EndOfMonth = 31
Case 11
EndOfMonth = 30
Case 12
EndOfMonth = 31
End Select
End Function
看看这是我代码,垃圾一大堆。
原来只要将下月第一天减掉一天就是当月天数,自己忘记还有DateSerial这个函数
谢谢hi-wzj
'求月末日期
Function 月末(日期 As Date) As Date
月末 = DateSerial(Year(日期), Month(日期) + 1, 0)
End Function
[em01] |
|