DateDiff Function in VB.NET

How to use DateDiff Function?


DateDiff Function

DateDiff Function in Visual 2008 is used to return a long value specifying the number of time intrevals between the specified date values.


Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim d1 As Date = #2/4/2009#
Dim d2 As Date = #2/4/2010#
Dim res As Long
res = DateDiff(DateInterval.Day, d1, d2)
MsgBox("The number of time intrevals between the dates
is::" & res)
End Sub
End Class

In the above DateDiff Function example, the time intrevals between two same dates of different years are found using the 'DateDiff()'. The function returns '365'.

Visual Basic Tutorial

Ask Questions

Ask Question