Basically what I am trying to achieve is:
- if from date is entered then date >= from date
- if to date is entered then date <= to date
- if both are entered then date >= from date and date <= to date
So on my page I have two date boxes where users can choose a from and to date. The problem is when I enter for example the below, I get items which actually have a date greater than 05/04/2012, which should not happen. My from date seems to work but the to date filter never works as it always returns results which are greater than the to date.
if (finalApprovedFromDate != DateTime.MinValue)
{
filteredClaims = filteredClaims.Where(cl => cl.claimStatus.Any(cs => cs.createdDate >= DateTime.Parse("05/03/2012"))).ToList();
}
if (finalApprovedToDate != DateTime.MinValue)
{
filteredClaims = filteredClaims.Where(cl => cl.claimStatus.Any(cs => cs.createdDate <= DateTime.Parse("05/04/2012"))).ToList();
}
Any ideas?
Modification to the query per comments. This will return only claims with a claim status of statusId 5 between 5/3 and 5/4.