I trying to find a simple way to solve this.
I have a Initial Date, and a Final Date.
And I want to generate a List<Datetime>
with each of the dates in a given period.
Example : Initial Date is "2013/12/01" and Final Date is "2013/12/05".
And I want to automatically populate a list with
"2013/12/01"
"2013/12/02"
"2013/12/03"
"2013/12/04"
"2013/12/05"
What would you suggest me?
Thanks
Using Pandas to Create a List of Range of Dates in Python. We will use the date_range() function of pandas in which we will pass the start date and the number of days after that (known as periods). Here we have also used the datetime library to format the date so that we can output the date in this format DD-MM-YY .
var startDate = new DateTime(2013, 12, 1);
var endDate = new DateTime(2013, 12, 5);
var dates = Enumerable.Range(0, (int)(endDate - startDate).TotalDays + 1)
.Select(x => startDate.AddDays(x))
.ToList();
for(var day = from.Date; day.Date <= end.Date; day = day.AddDays(1))
{
list.Add(day);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With