devxlogo

BusinessDateAdd – Adding or subtracting a number of business days from a date

BusinessDateAdd – Adding or subtracting a number of business days from a date

' Add or subtract a number of business days from a date' Example: Debug.WriteLine(BusinessDateAdd(#4/9/2003#, 5)) ' => 4/16/2003Function BusinessDateAdd(ByVal startDate As Date, ByVal days As Integer, _    Optional ByVal saturdayIsHoliday As Boolean = True) As Date    Do While days        ' increment or decrement the date        startDate = startDate.AddDays(Math.Sign(days))        ' check that it is a week day        If startDate.DayOfWeek <> DayOfWeek.Sunday AndAlso (startDate.DayOfWeek _            <> DayOfWeek.Saturday Or Not saturdayIsHoliday) Then            ' days becomes closer to zero            days -= Math.Sign(days)        End If    Loop    Return startDateEnd Function

See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist