VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



RemoveWeekEnds

by Ustes (6 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Returns number of business days from a start date and total number of days. There are more pieces coming. Building a routine that calculates holidays and weekends to tell you strictly business days.

Inputs
strStartDate and totalsdays
Code Returns
total number of business days

Rate RemoveWeekEnds

Public Function RemoveWeekends(strStartDate As String, intNumberOfDays) As Integer
  Dim i As Integer
  
  For i = 0 To intNumberOfDays
    Select Case Weekday(DateAdd("d", i, CDate(strStartDate)))
      Case vbSaturday, vbSunday
        intNumberOfDays = intNumberOfDays - 1
    End Select
  Next i
  RemoveWeekends = intNumberOfDays
End Function

Download this snippet    Add to My Saved Code

RemoveWeekEnds Comments

No comments have been posted about RemoveWeekEnds. Why not be the first to post a comment about RemoveWeekEnds.

Post your comment

Subject:
Message:
0/1000 characters