When you do an equality comparison, you're right when comparing the full DateTime representation, to be honest, it compares the equality of the Ticks property of each DateTime object.
public static bool operator ==(DateTime d1, DateTime d2) { return d1.InternalTicks == d2.InternalTicks; }
(from reference source )
If you only need the equality Date (year, month, day) and Time (hours, minute, seconds), you need to implement something like the following:
IEnumerable<ValidateTaskSummaryDetails> source; source = source.Where(o => o.TaskStartDate.Value.Year == dtStartDate.Year && o.TaskStartDate.Value.Month == dtStartDate.Month && o.TaskStartDate.Value.Day == dtStartDate.Day && o.TaskStartDate.Value.Hour == dtStartDate.Hour && o.TaskStartDate.Value.Minute == dtStartDate.Minute && o.TaskStartDate.Value.Second == dtStartDate.Second);
Or a comparison of string representation equality in the required format.
var format = "dd/MM/yyyy HH:mm:ss"; source = source.Where(o => o.TaskStartDate.Value.ToString(format) == dtStartDate.ToString(format));
The first approach will be faster because it requires comparing numeric fields instead of string . It should be noted (as noted in the comments) that converting a DateTime to a string and comparing this string representation is kind of a bad idea, and this is a good example of bad smell code. It will give the desired results, but you should avoid it - string comparisons are always worse than numeric comparisons.
It is recommended to avoid comparing comparisons of DateTime objects, since there are too many variables that affect the result (Hour, Minute, Second, Day, Month, Year, Millisecond) and only comparisons of inequalities are performed (<, <=,>,> =). Or compare only the Date DateTime component as follows:
source = source.Where(o => o.TaskStartDate.Value.Date == dtStartDate.Date);
Often for most common applications this is enough.