Next Working Day : Date Time Function « Date Time « VB.Net






Next Working Day

   
Public Class MainClass
    Public Shared Sub Main()
        Dim datNewDate As Date = AddWorkingDays(Today, 1)
        System.Console.WriteLine(datNewDate)
    End Sub

    Public Shared Function AddWorkingDays(ByVal DateIn As Date, ByVal ShiftDate As Integer) As Date
        Dim datDate As Date = DateIn.AddDays(ShiftDate)
        While Weekday(datDate) = 1 Or Weekday(datDate) = 7
            datDate = datDate.AddDays(IIf(ShiftDate < 0, -1, 1))
        End While
        Return datDate
    End Function


End Class

   
    
    
  








Related examples in the same category

1.Date Time related FunctionDate Time related Function
2.Years Between Dates
3.Parse(String) method returns a DateTime value whose Kind property is DateTimeKind..::.Unspecified
4.Parse(String) parses date and time values using the formatting conventions of the en-US culture
5.Generic and nongeneric versions of the CompareTo method for DateTime value