How to compare just the date part and not the time of two Dates?

Ylva D picture Ylva D · Mar 6, 2009 · Viewed 86.8k times · Source

I want to compare just the date part (and Not the time) of two VB.NET Date objects. Is there a way to do that?

Answer

Jon Skeet picture Jon Skeet · Mar 6, 2009

Just take the date part of each via the Date property and compare the two:

date1.Date.CompareTo(date2.Date)

Or:

If date1.Date < date2.Date Then