|
我本人在access这个论坛上受益不多,多蒙受各位老师指点,今有心得,写一自定月份的函数,与大家一起分享...
Public Function MyMonth(MyDate As Date, last_day As Integer) As String
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
Dim S As String
intYear = Year(MyDate)
intMonth = Month(MyDate)
intDay = Day(MyDate)
If intDay > last_day Then
intMonth = intMonth + 1
If intMonth > 12 Then
intYear = intYear + 1
intMonth = 1
End If
End If
S = intYear & "年" & Right("00" & intMonth, 2) & "月"
MyMonth = S
End Function
调试成功:
? mymonth(#2008-12-21#,20)
2009年01月
? mymonth(#2008-12-21#,25)
2008年12月 |
|