MRu MRu - 1 year ago 89
C# Question

How to compare with a certain date?

Let's say i have a variable of datetime type; varA = '2016-06-10 12:28:36.697'. What is the best way and how i can compare it with
to make sure the date is the same regardless of the year?

Rob Rob
Answer Source

It's unclear if you want to include the time part of the DateTime as well, or simply the Day and Month. Uncomment/tweak for your use:

bool AreEqual(DateTime left, DateTime right)
    return left.Day == right.Day && left.Month == right.Month
        // && left.TimeOfDay.Equals(right.TimeOfDay)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download