DateTime.Equals Method (DateTime, DateTime)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns a value indicating whether two DateTime instances have the same date and time value.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Function Equals (
	t1 As Date,
	t2 As Date
) As Boolean


Type: System.DateTime

The first object to compare.

Type: System.DateTime

The second object to compare.

Return Value

Type: System.Boolean

true if the two values are equal; otherwise, false.

t1 and t2 are equal if their Ticks property values are equal. TheirKind property values are not considered in the test for equality.

The following example demonstrates the Equals method.

Dim today1 As New System.DateTime(System.DateTime.Today.Ticks)
Dim today2 As New System.DateTime(System.DateTime.Today.Ticks)
Dim tomorrow As New System.DateTime( _

' todayEqualsToday gets true.
Dim todayEqualsToday As Boolean = System.DateTime.Equals(today1, today2)

' todayEqualsTomorrow gets false.
Dim todayEqualsTomorrow As Boolean = System.DateTime.Equals(today1, tomorrow)

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top