title: Calculating Business Minutes form 2 dates excluding weekends
body: <p>I have the following code which calculates business minutes from 2 dates given. Where 9am is the start time and 5.30pm is finish time. However, how can I also incorporate a rule where I can prevent weekend hours being included? I am having such a mind block here :/</p>
  
  <pre><code>Function ElapsedBusinessMinutes(StartDateTime As Date, StopDateTime As Date) As Single
  Dim dteAdjStart As Date
  Dim lngElapsedMinutes As Long
  Dim lngMinutesInWorkDay As Long
  lngMinutesInWorkDay = 510
  dteAdjStart = TimeValue(StartDateTime)
  If dteAdjStart &gt; #5:30:00 PM# Then
    dteAdjStart = TimeSerial(7, Minute(StartDateTime), Second(StartDateTime))
    lngElapsedMinutes = DateDiff("d", StartDateTime, StopDateTime - 1) * lngMinutesInWorkDay
  Else
    lngElapsedMinutes = DateDiff("d", StartDateTime, StopDateTime) * lngMinutesInWorkDay
  End If
  ElapsedBusinessMinutes = lngElapsedMinutes + DateDiff("n", dteAdjStart, TimeValue(StopDateTime))
  End Function
  </code></pre>