MRu MRu - 14 days ago 4x
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

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)