Compare two DateTime values using equal operator in VB.NET

This blog defines the Comparison of two DateTime values.

Equal operator

Returns a value that indicating weather this instance is equal to the specified to the system.datetime instance.In this blog we compare two DateTime values.

Module Module1

    Sub Main()

        Dim First As DateTime = DateTime.UtcNow

        Dim second As DateTime = DateTime.Now

        Dim third As DateTime = First

        Dim result As Boolean = First.Equals(second)

        Console.WriteLine("comparing DateTime object first and second is: {0}.", result)

        result = First.Equals(third)

        Console.WriteLine("comparing DateTime object first and third is: {0}.", result)

    End Sub

End Module

 

OUTPUT

 

c2.gif