N
NadSadBad
Hi,
I have the following module with the following code in it. It basically is
used to calculate the difference between 2 date values and excludes weekends
(Saturday and Sunday):
Function DateDiffXWE(stDate As Date, fiDate As Date) As Integer
Dim nDays As Integer
nDays = 0
While stDate < fiDate
stDate = DateAdd("d", 1, stDate)
If Weekday(stDate) > 1 And Weekday(stDate) < 7 Then
nDays = nDays + 1
End If
Wend
DateDiffXWE = nDays
End Function
Now in a query, I have placed the following formula in one of the columns:
DateDiffXWE([tabActualExpenditure].[CreatedOn],[tabClientDetails].[TerminationDateUpdated]) and the criteria for it is <=10.
When I run the report that runs the query with the above formula, it takes
absolutely ages to run, in fact its just keeps running all the time and the
report I think will never appear, which I have been told is happening because
the code is running in a loop and that queries don’t like formulas like this.
Can someone please advise what I can do to reduce the time for this query to
run, is it wise to use this formula and what are my alternatives to reduce
time.
I desperately need help on this.
Thanks in advance
I have the following module with the following code in it. It basically is
used to calculate the difference between 2 date values and excludes weekends
(Saturday and Sunday):
Function DateDiffXWE(stDate As Date, fiDate As Date) As Integer
Dim nDays As Integer
nDays = 0
While stDate < fiDate
stDate = DateAdd("d", 1, stDate)
If Weekday(stDate) > 1 And Weekday(stDate) < 7 Then
nDays = nDays + 1
End If
Wend
DateDiffXWE = nDays
End Function
Now in a query, I have placed the following formula in one of the columns:
DateDiffXWE([tabActualExpenditure].[CreatedOn],[tabClientDetails].[TerminationDateUpdated]) and the criteria for it is <=10.
When I run the report that runs the query with the above formula, it takes
absolutely ages to run, in fact its just keeps running all the time and the
report I think will never appear, which I have been told is happening because
the code is running in a loop and that queries don’t like formulas like this.
Can someone please advise what I can do to reduce the time for this query to
run, is it wise to use this formula and what are my alternatives to reduce
time.
I desperately need help on this.
Thanks in advance