Are they the same day?

G

Guest

Hello, friends,

What is the best way to test if two date values are the same day (same hour)
or not in c#.net?

As you know, in VB6, we have a fuction DateDiff("d", date1, date2). Do we
have a similar one in .net?

Thanks.
 
J

Jon Skeet [C# MVP]

Andrew said:
What is the best way to test if two date values are the same day (same hour)
or not in c#.net?

if (day1.Date==day2.Date)
{
...
}

and

if (day1.Date==day2.Date &&
day1.TimeOfDay.Hours==day2.TimeOfDay.Hours)
{
...
}
 

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

Top