Compare Datetime C# Greater Than – Programming, Pseudocode Example, C# Programming Example
Basic C# Console General

Compare Datetime C# Greater Than

Example 1: The first instance is a simple example. Datetime.Compare method compares two dates that are created as objects.

DateTime.Compare(date1,date2) : It is used to compare two dates.  Method can return only 1, 0 or -1

If d1 is greater than d2 it returns 1

If d2 is greater than d1 it returns -1

if dates are equel to each other it returns 0

Here are the codes

 

Example 2: Comparing two dates in the C# DataGridView

In this example shows us, how to compare two date in dataGridView using C# Windows Form Application.

Source Code:

Output:

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.