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

Wayne srilyk at gmail.com
Fri Oct 9 22:29:16 CEST 2009


On Fri, Oct 9, 2009 at 2:16 PM, Glen Zangirolami <digitalman66 at gmail.com>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 ;)
>

The datetime module exists... you could easily write a function that does
something along the lines of:

def date_range(startdate, enddate):
     #do something here to make a range of dates

though you may want to write a function that checks for a missing date
first.

HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091009/d0d021f1/attachment.htm>


More information about the Tutor mailing list