Given a start date of 1/1/2009 and an end date of 12/31/2009, how can I iterate through each date and retrieve a DateTime value using c#?
Thanks!
DateTime current = DateTime.Parse("1/1/2009");
DateTime nextYear = current.AddYears(1);
do
{
Console.WriteLine(current);
current = current.AddDays(1);
} while (current < nextYear) ;
I would use a loop that looks like this
for(DateTime date = begin; date <= end; date = date.AddDays(1))
{
}
Set begin and end accordingly