Check if the Date
part of the datetime is the same. If so, adjust the values accordingly
if(firstDate.Date.Equals(secondDate.Date))
{
firstDate = firstDate.Date;
//If any time of day was set, it's now 0:00:00
secondDate = firstDate.AddDays(1).AddSeconds(-1);
//This is now the day with time 23:59:59
}
At that point, you can continue your regular filtering.