|
我是这样改的的,高手看有没有毛病,感谢wu8313 huanghai 以及大家的帮助Option Compare DatabaseFunction months_count(allMonths As Integer, Y As Integer, M As Integer) As String
' Dim allMonths As Integer '总共多少个月
' Dim Y As Integer, M As Integer
' allMonths = DateDiff("m", #5/23/1981#, #3/5/2005#) Y = Int(allMonths / 12) '在查询中调用的时候,根据字段名称作了相应更改 y=[时间差]/12 M = allMonths Mod 12 '在查询中调用的时候,根据字段名称作了相应更改 m=[时间差] mod 12 If M > 0 And Y <> 0 Then
Debug.Print Y & "年零" & M & "个月"
months_count = Y & "年零" & M & "个月"
Else Debug.Print Y & "年整"
months_count = Y & "年整" End If
If Y = 0 Then
Debug.Print M & "个月"
months_count = M & "个月"
End If
End Function
|
|