SELECT [Enter a Start date] AS StartDate, [your date field],
calcwkdays2([Enter a Start date],[your date field],False) AS NumDays
FROM [your table name]
WHERE ((([your date field])>=[Enter a Start date]));
Function CalcWkDays2(dteStartDate As Date, dteEndDate As Date, _
YCnt As Boolean, Optional pExcl As String = "17") As Integer
'*****************************************************
'Name: CalcWkDays2 (Function)
'Purpose: Count # of days between two dates, with
' options to:
' (1) Include or exclude the start date in count
' (2) Specify weekdays to exclude (default
' set to Saturday (7) & Sunday (1). To exclude
' Tuesday (3) & Thursday (5), specify "35".
'Parameters: dteStartDate & dteEndDate formatted as dates
' YCnt: Specify True to include start date in
' count, False to exclude it.
' pExcl: Weekdays to exclude
'Inputs: From debug window:
' (1) ? CalcWkDays2(#01/01/01#, #07/01/01#, True)
' (2) ? CalcWkDays2(#01/01/01#, #07/01/01#, False)
' (3) ? CalcWkDays2(#01/01/01#, #07/01/01#, True, "")
' (4) ? CalcWkDays2(#01/01/01#, #07/01/01#, False,"")
' (5) ? CalcWkDays2(#07/01/01#, #01/01/01#, False,"")
' (6) ? CalcWkDays2(#01/01/01#, #07/01/01#, False,"23456")
'Output: (1) 130; (2) 129; (3) 182; (4) 181; (5) -181; (6) 52
'
'*****************************************************
Dim n As Integer, wdays As String, dateHold As Date, dteFlag As Boolean
dteFlag = False
'Reverse the dates if they were input backwards
If dteStartDate > dteEndDate Then
dateHold = dteStartDate
dteStartDate = dteEndDate
dteEndDate = dateHold
dteFlag = True
End If
n = 0
dteStartDate = dteStartDate - Not (YCnt)
'days to exclude (7 & 1 unless other specified)
wdays = pExcl
Do While dteStartDate <= dteEndDate
n = n + IIf(InStr(wdays, WeekDay(dteStartDate)) = 0, 1, 0)
dteStartDate = dteStartDate + 1
Loop
'return negative value if the Start Date
'was initially greater than the End Date
CalcWkDays2 = n * IIf(dteFlag, -1, 1)
End Function