compare two dates?

  • Thread starter Thread starter Dirk Reske
  • Start date Start date
D

Dirk Reske

Hello,

I have two dates.
How can I check if the second date is the day after the first date?

thx
 
Hello,

Try something like this.

Date1.AddDays(1).equals(Date2))

Peter
 
I think this way will do what he need ..

if (DateTime.Compare(date1, date2) > 0) Console.Write("date1 > date2");
if (DateTime.Compare(date1, date2) == 0) Console.Write("date1 == date2");
if (DateTime.Compare(date1, date2) < 0) Console.Write("date1 < date2");

Nirosh.
 
Dirk Reske said:
Hello,

I have two dates.
How can I check if the second date is the day after the first date?

The DateTime struct supports the >, <=, >= and < operators.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top