I have a query in which I am using a between statement to pull data for a date range. I have a VBA function built, that will evaluate the last date (Max Date) in a table (to get the 1st date for the between) and another function to evaluate the stop date (last date of the between)...So my between date statement looks like this: Between hhMaxDte() And hhLastDte()
For some reason having these 2 functions in my between statement takes what seems to be 8x longer to run the query than if I just manually put the actual dates in myself. Anyone out there know why this is and how I can dynamically do a similar process, but take the same amount of time to run the query, as when I manually enter the dates? My functions code is below:
Function hhMaxDte()
If DMax("row_date", "HH_CIB_Raw_Data") + 1 = Date Then
hhMaxDte = 0
Else
hhMaxDte = DMax("row_date", "HH_CIB_Raw_Data") + 1
End If
End Function
Function hhLastDte()
If DMax("row_date", "HH_CIB_Raw_Data") + 1 = Date Then
hhLastDte = 0
Else
hhLastDte = Date - 1
End If
End Function