Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: Intermediate
Jun 9, 2003



Application Security Testing: An Integral Part of DevOps

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/2003

Function 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
    Return startDate
End Function
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date