Compare the difference between two Date value with Ticks
Imports System.Globalization
Module MainClass
Public Sub Main()
Dim dateFormat As String = "MM/dd/yyyy hh:mm:ss.fffffff"
Dim date1 As Date = #09/08/2010 16:00#
Console.WriteLine("Original date: {0} ({1:N0} ticks)", _
date1.ToString(dateFormat), date1.Ticks)
Dim date2 As Date = date1.AddMilliseconds(1)
Console.WriteLine("Second date: {0} ({1:N0} ticks)", _
date2.ToString(dateFormat), date2.Ticks)
Console.WriteLine("Difference between dates: {0} ({1:N0} ticks)", _
date2 - date1, date2.Ticks - date1.Ticks)
End Sub
End Module
Related examples in the same category