I have two DateTimes, and I want to get all DateTimes between these Dates. Such as, if my Dates are like 01.01.2010 - 05.01.2010, my function shoul
Here is a quick console app to demonstrate how to do it - use AddDays() instead:
class Program
{
static void Main(string[] args)
{
GetDates(new DateTime(2010, 1, 1), new DateTime(2010, 2, 5));
Console.ReadKey();
}
static List GetDates(DateTime startDate, DateTime endDate)
{
List dates = new List();
while ((startDate = startDate.AddDays(1)) < endDate)
{
dates.Add(startDate);
}
return dates;
}
}