I have a Generic DateTime List
List<DateTime> **PreviousDates** = //Some List of Dates
Now i want to Get all the Dates in the PreviousDates List whose Month and Year equals the GivenDate’s Month & Year. no matter what the Day & Time are…
I Tried using List.Contains() method, but it checks all Parts of the Date, i want to check only Month&Year..
Help Me!
Thanks
Pradeep
You can create
DateTimevalues for the start and end of the interval:Now you can easily select the items that is inside the interval:
(You could of course compare the
GivenDate.YearandGivenDate.Monthvalues tod.Yearandd.Monthin theWhere, but that’s a more complex and less efficient condition.)