Option Compare Database
Public Function DateDiffW(BegDate As Date, EndDate As Date) As Integer
'Returns number of days, excluding Saturday and Sunday
'As written, counts both BegDate and EndDate, e.g.,
'Monday - Friday would count as 5 days
'coded by: raskew
Const SUNDAY = 1
Const SATURDAY = 7
Dim NumWeeks As Integer
This is my function
'If BegDate > EndDate Then
DateDiffW = 0
Else
Select Case Weekday(BegDate)
Case SUNDAY: BegDate = BegDate + 1
Case SATURDAY: BegDate = BegDate + 2
End Select
Select Case Weekday(EndDate)
Case SUNDAY: EndDate = EndDate - 2
Case SATURDAY: EndDate = EndDate - 1
End Select
NumWeeks = DateDiff("ww", BegDate, EndDate)
DateDiffW = NumWeeks * 5 + Weekday(EndDate) - Weekday(BegDate)
End If
End Function'
This is my query
Fine: IIF(DateDiffw([Due Date],[Return_Date])<=14,Datediffw([DueDate],[Return_Date])*0.2,Datediffw([Due Date],[Return_Date])*0.2+1)
I have saved the vba as 'DateDiffW' but when running the query, i get the error, undefined function datediffw in expression, any ideas for help?
Public Function DateDiffW(BegDate As Date, EndDate As Date) As Integer
'Returns number of days, excluding Saturday and Sunday
'As written, counts both BegDate and EndDate, e.g.,
'Monday - Friday would count as 5 days
'coded by: raskew
Const SUNDAY = 1
Const SATURDAY = 7
Dim NumWeeks As Integer
This is my function
'If BegDate > EndDate Then
DateDiffW = 0
Else
Select Case Weekday(BegDate)
Case SUNDAY: BegDate = BegDate + 1
Case SATURDAY: BegDate = BegDate + 2
End Select
Select Case Weekday(EndDate)
Case SUNDAY: EndDate = EndDate - 2
Case SATURDAY: EndDate = EndDate - 1
End Select
NumWeeks = DateDiff("ww", BegDate, EndDate)
DateDiffW = NumWeeks * 5 + Weekday(EndDate) - Weekday(BegDate)
End If
End Function'
This is my query
Fine: IIF(DateDiffw([Due Date],[Return_Date])<=14,Datediffw([DueDate],[Return_Date])*0.2,Datediffw([Due Date],[Return_Date])*0.2+1)
I have saved the vba as 'DateDiffW' but when running the query, i get the error, undefined function datediffw in expression, any ideas for help?