How to determine if birthday or anniversary occured during date range
Posted
by davekaro
on Stack Overflow
See other posts from Stack Overflow
or by davekaro
Published on 2010-03-31T14:16:57Z
Indexed on
2010/03/31
14:23 UTC
Read the original article
Hit count: 262
Given I have a birthday/anniversary DateTime, how can I determine if that date occurred during a specific date range? For example,
Birthday = 1/2/2000
Date Range = 12/25/2008 - 1/3/2009
I need a method to determine whether or not this person's birthday happened during that date range - preferably in C#.
I first went about changing the year of the birthday DateTime to match the date range, then just check if the "new" birthday DateTime is between the start and end date of the date range... but when the date range spans different years, like in my example above - I had to add a nasty if statement. Is there no better way?
© Stack Overflow or respective owner