In this article, you will learn how to compare two dates without time in C#. Sometimes, we need to compare only the date parts of two DateTime variables in C#. So here in this article, we used the ==
operator and .CompareTo()
method to compare the two dates without time in C#.
Here are the examples to compare two dates without time in C#.
In this example, we compare the two dates without time using the equality == operator, if both dates are the same then it will return true otherwise it will return false.
Here is the source code of the program to compare two dates without time using == Operator in C#.
In this example, we compare the value of this instance to a specified DateTime
value and indicate whether this instance is earlier than, the same as, or later than the specified DateTime
value.
A number indicating the relative values of this instance and the value parameter.
Compare Return Value:
Here is the source code of the program to compare the two dates without time using the .CompareTo() method in c#.
I hope this article will help you to understand how to compare two dates without time in C#.
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments