Function NumberOfHours(dStart As Date, dEnd As Date) As Double
Dim dbDIF As Double
Dim dLoop As Date
Dim iCount As Integer
Const iMIN As Integer = 15
For dLoop = dStart To dEnd Step DateAdd("n", iMIN, dLoop)
If Weekday(dLoop) > vbSunday And Weekday(dLoop) < vbSaturday Then
'If DatePart("H", dLoop) = 8 Then Stop
If Format(dLoop, "hhnn") > Format("8:00 AM", "hhnn") And _
Format(dLoop, "hhnn") <= Format("12:00 PM", "hhnn") Then
iCount = iCount + iMIN
ElseIf Format(dLoop, "hhnn") > Format("1:00 PM", "hhnn") And _
Format(dLoop, "hhnn") <= Format("5:00 PM", "hhnn") Then
iCount = iCount + iMIN
End If
End If
Next
NumberOfHours = iCount / 60
End Function
Call Example from Debug Window
?NumberOfHours(#3/22/2002 08:00#,#3/25/2002 16:00#)