VB.Net/Development/Date Time Function
<source lang="vbnet"> Imports System.IO Module Module1
Sub Main() Dim DT As DateTime = Now() Console.WriteLine("Day: " & Day(DT).ToString) Console.WriteLine("Month: " & Month(DT)) Console.WriteLine("Year: " & Year(DT)) Console.WriteLine("Hour: " & Hour(DT)) Console.WriteLine("Minute: " & Minute(DT)) Console.WriteLine("Second: " & Second(DT)) Console.WriteLine("Today: " & Today) Console.WriteLine("TimeOfDay: " & TimeOfDay().ToString()) End Sub
End Module
</source>
Next Working Day
<source lang="vbnet"> 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
</source>
Years Between Dates
<source lang="vbnet"> Public Class MainClass
Public Function YearsBetweenDates(ByVal StartDate As DateTime, ByVal EndDate As DateTime) As Integer If Month(EndDate) < Month(StartDate) Or (Month(EndDate) = Month(StartDate) And(EndDate.Day) < (StartDate.Day)) Then Return Year(EndDate) - Year(StartDate) - 1 Else Return Year(EndDate) - Year(StartDate) End If End Function
End Class
</source>