So now I have re-written the function to take into consideration dates passed as Dates or strings, and allow the caller pass what the first day of week is, and if week days are included or not:
Public Function TimeElapsed(ByVal vStartDateTime As Variant, ByVal vEndDateTime As Variant, _
Optional ByVal bWeekDaysOnly As Boolean = True, _
Optional ByVal iFirstDayOfWeek As VbDayOfWeek = vbUseSystemDayOfWeek) As Single
Dim dCalc As Single
Dim dtTestDate As Date
Dim iLoop As Integer
Dim iTotalDays As Integer
Dim iDayType As VbDayOfWeek
'************************************
'REMOVE- For testing only
'vStartDateTime = "01/01/02" & " " & "12:30:00"
'vEndDateTime = "02/28/02" & "" & "02:00:00"
'************************************
If Not IsDate(vStartDateTime) Or Not IsDate(vEndDateTime) Then Exit Function
If DateValue(vStartDateTime) > DateValue(vEndDateTime) Then Exit Function
'If dates are passed as a string, then take into consideration international formats:
vStartDateTime = CDate(vStartDateTime)
vEndDateTime = CDate(vEndDateTime)
'Get the difference in days
dCalc = DateDiff("d", vStartDateTime, vEndDateTime)
'Subtract 1 day because we only want whole days and do not want to include the start and end date
If dCalc > 0 Then dCalc = dCalc - 1
'If dCalc is still > 0 days then determine how many actual workdays there are if this option is set to TRUE:
If bWeekDaysOnly Then
iTotalDays = dCalc
For iLoop = 1 To iTotalDays
dtTestDate = DateAdd("d", iLoop, vStartDateTime)
iDayType = Weekday(dtTestDate, iFirstDayOfWeek)
If iDayType = vbSaturday Or iDayType = vbSunday Then dCalc = dCalc - 1
Next iLoop
End If
'CONTINUED....