Possible Duplicate:
Iterating through a range of dates in Python
I have two entries:
date1 = 2004.09.25
date2 = 2004.10.08
I want to wrote a script in Python that recognizes the date range and print them. something like this:
for i in range(date1:date2):
print i
Do I need to define the dates in a particular format for dates?
The expected output is like:
2004.09.25
2004.09.26
.
.
.
2004.10.08
Your first step should have been to look at the python datetime library.
Overall, your first solution could look something like this:
(one thing to note: this will obviously clobber your
date1variable)I would later refactor this into a daterange function so that you can do something closer to what you did; it would look like
Later on, when you develop your python skills, it could like like this:
Or this, which would be my final version: