Why not save the Birthday in a local variable, change the year to the current year, and then check to see if this happens in the next 20 days?
public bool IsBirthdayInNextTwentyDays(DateTime actualBirthday) { var birthday = actualBirthday; birthday.Year = DateTime.Now.Year; return birthday > DateTime.Now && birthday < DateTime.Now.AddDays(20); }
Then in Linq something like:
user.Where(u => IsBirthDayInNextTwentyDays(u.Birthday));
Kindness,
Dan
source share