我正在運行下面的表達式來比較兩個日期的差異。如果兩個日期都在單元格中,我希望它返回0,但如果Date2是空白,我希望顯示差異。現在,如果date2中沒有日期,我只會得到#ERROR。任何想法將不勝感激。如果值爲空白,QRY返回錯誤?
expr2: NetWorkDays([Date1],[Date2])
Option Compare Database
Public Function NetWorkdays(dteStart As Date, dteEnd As Date) As Integer
Dim intGrossDays As Integer
Dim dteCurrDate As Date
Dim i As Integer
intGrossDays = DateDiff("d", dteStart, dteEnd)
NetWorkdays = 0
For i = 0 To intGrossDays
dteCurrDate = dteStart + i
If Weekday(dteCurrDate, vbMonday) < 6 Then
End If
Next i
End Function
什麼是你打算用'做NETWORKDAYS = 0' – talbright 2012-07-19 19:13:30
有時該字段爲空,如果是,我需要知道自輸入第一個字段日期以來它已空白多長時間 – user1342164 2012-07-19 20:15:27
您可以請在您要調用函數的地方發佈代碼嗎? – talbright 2012-07-20 12:56:48