the background
this code is called by a query in Access that runs for approx 35,000 data points. It takes 2-3 hours to run.

Anyway to make it faster???

Here's the calling query:
HTML Code:
UPDATE tbl_TMS_Orders_VendorNumber SET tbl_TMS_Orders_VendorNumber.TMSAcknowledgementDays = IIf(getbusinessdaysdiff(nz([tbl_TMS_Orders_VendorNumber].[ORD ISSUED DATE],#1/1/1900#),nz(([tbl_TMS_Orders_VendorNumber].[ORD ORIGIN PLANNED DEPART (S)DATE]-3),#1/1/1900#))<>-100000,getbusinessdaysdiff(nz([tbl_TMS_Orders_VendorNumber].[ORD ISSUED DATE],#1/1/1900#),nz(([tbl_TMS_Orders_VendorNumber].[ORD ORIGIN PLANNED DEPART (S)DATE]-3),#1/1/1900#)),Null);

Here's the function code:
HTML Code:
Public Function GetBusinessDaysDiff(d1 As Date, d2 As Date) As Long

Dim rs As Recordset
Dim sql As String
Dim retval As Long

    
  If DateDiff("D", d1, "1/1/1900") = 0 Or DateDiff("D", d2, "1/1/1900") = 0 Then
      
    retval = -100000
    
  Else
    
    sql = "select count(dateid) as result from tblFiscalCalendar where BusinessDay=true and " & _
          "dateid <> #" & d1 & "# and dateid between #" & d1 & "# and #" & d2 & "#;"
    
    Set rs = CurrentDb.OpenRecordset(sql)
    
    retval = rs![result]
    
    If d2 > d1 Then
        retval = retval * -1
    End If
    
  End If