Here is sample code for listing the all dates for between two dates
from dateutil import rrule
from datetime import datetime
def get_date_range(date_from, date_to):
date_list = []
for dd in rrule.rrule(rrule.DAILY,
dtstart=datetime.strptime(date_from, "%Y-%m-%d"),
until=datetime.strptime(date_to, "%Y-%m-%d")):
date_list.append(datetime.strftime(dd,"%Y-%m-%d"))
return date_list
date_from = '2013-11-02'
date_to = '2013-11-13'
date_data = get_date_range(date_from, date_to)
print "List Dates ::::::",date_data
O/P :
List Dates :::::: ['2013-11-02', '2013-11-03', '2013-11-04', '2013-11-05', '2013-11-06', '2013-11-07', '2013-11-08', '2013-11-09', '2013-11-10', '2013-11-11', '2013-11-12', '2013-11-13']
No comments:
Post a Comment