Wednesday, 7 August 2013

C# Way to compare DateTime with mask

C# Way to compare DateTime with mask

Let's say, we have a DateTime with some fields set, ex. only Month and
Day. It's a mask. And we want to filter list of DateTimes through this
mask:
match X, if X has Month and Day same as mask, and any other values in
other fields, if mask has them unset (zeros).
Of course, I can do it whth a lot of comparsions for each possible field,
but I believe in .NET library. I'm looking for a good way of doing this,
either with or without LINQ.
Real-world usage of this is like specifying a year to find all
corresponding entries for this year, or specifying month and day to find
everything for these month and day (any year and time)

No comments:

Post a Comment