[Tutor] Finding and Inserting missing dates in a date range.

Tim Golden mail at timgolden.me.uk
Fri Oct 9 22:41:06 CEST 2009

Glen Zangirolami wrote:
> If i have a list of dates:date_list =
> ['2008-12-29','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-05']
> How do I find the missing dates in the range of dates and insert them into
> the list so I get?
> date_list =
> ['2008-12-29','2008-12-30','2008-12-31','2008-01-01','2008-01-02','2008-01-03','2008-12-04','2008-01-05']
> Hopefully the case is that I haven't found the correct python module that
> does it ;)

I'd be inclined to combine datetime.strptime
with a date-ranging function and some set work.


More information about the Tutor mailing list