0

I am interested in generating dates for a week, given a start date and end date.

Here is the code.

from datetime import date,time,datetime
from dateutil.rrule import rrule, WEEKLY


def getDates(start_date,end_date):
    for dt in rrule(WEEKLY, dtstart=start_date, until=end_date):
        print dt.strftime("%Y-%m-%d")

a = datetime.strptime("2014-01-01","%Y-%m-%d")
b = datetime.strptime("2014-02-01","%Y-%m-%d")
print getDates(a,b)

But, I am unable use it as a function. Can you please provide some help on this.

Jon Clements
  • 132,101
  • 31
  • 237
  • 267
Vidu
  • 1
  • 1
    What do you mean by "unable use it as a function"? Your function when called will print the data, it doesn't return/yield anything... What exactly do you want to do? – Jon Clements Dec 03 '14 at 18:32
  • possible duplicate of [Generate a list of datetimes between an interval in python](http://stackoverflow.com/questions/10688006/generate-a-list-of-datetimes-between-an-interval-in-python) – BorrajaX Dec 03 '14 at 18:47

0 Answers0