[AccessD] Calculating DateDiff for Workdays

Mike & Doris Manning mikedorism at verizon.net
Tue Jan 10 10:31:05 CST 2006


Here is a very easy function found at
http://www.databasejournal.com/features/msaccess/article.php/1552691

  Public Function GetNumberOfWorkDays(sStartDate, sEndDate)
    Dim iDays
    Dim iWorkDays
    Dim sDay
    Dim i
    
    iDays = DateDiff("d", sStartDate, sEndDate)
   
    iWorkDays = 0
   
    For i = 0 To iDays
      'First day of the week is sunday
      sDay = Weekday(DateAdd("d", i, sStartDate))
      If sDay <> 1 And sDay <> 7 Then
        iWorkDays = iWorkDays + 1
      End If
    Next
    GetNumberOfWorkDays = iWorkDays
  End Function

Doris Manning
mikedorism at verizon.net





More information about the AccessD mailing list