Determine work day number within month


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Function workdayNumber(TheDate As Date) As Byte
  2.  
  3. ' Determines the work day number within a month
  4.  
  5. Dim tempDate As Date
  6. Dim tempWeekDay As Byte
  7.  
  8. ' Start with the first day of the month
  9. tempDate = CDate(Format(TheDate, "m/1/yyyy"))
  10.  
  11. Do While Month(tempDate) = Month(TheDate)
  12. tempWeekDay = Weekday(tempDate)
  13. If (tempWeekDay > 1) And (tempWeekDay < 7) Then
  14. workdayNumber = workdayNumber + 1
  15. If tempDate = TheDate Then
  16. Exit Function
  17. End If
  18. End If
  19. tempDate = tempDate + 1
  20. Loop
  21.  
  22. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.