views:

251

answers:

1

Hi!
from ipython console:

In [16]: b
Out[16]: datetime.datetime(2008, 3, 1, 0, 0)

In [17]: e
Out[17]: datetime.datetime(2010, 5, 2, 0, 0)

In [18]: rrule(MONTHLY).between(b, e, inc=True)
Out[18]:
[datetime.datetime(2009, 3, 6, 14, 42, 1),
 datetime.datetime(2009, 4, 6, 14, 42, 1),
 datetime.datetime(2009, 5, 6, 14, 42, 1),
 datetime.datetime(2009, 6, 6, 14, 42, 1),
 datetime.datetime(2009, 7, 6, 14, 42, 1),
 datetime.datetime(2009, 8, 6, 14, 42, 1),
 datetime.datetime(2009, 9, 6, 14, 42, 1),
 datetime.datetime(2009, 10, 6, 14, 42, 1),
 datetime.datetime(2009, 11, 6, 14, 42, 1),
 datetime.datetime(2009, 12, 6, 14, 42, 1),
 datetime.datetime(2010, 1, 6, 14, 42, 1),
 datetime.datetime(2010, 2, 6, 14, 42, 1),
 datetime.datetime(2010, 3, 6, 14, 42, 1),
 datetime.datetime(2010, 4, 6, 14, 42, 1)]

How to make between() return dates starting from the begining (b) date?

regards
chriss

+5  A: 

You need to pass b into rrule, like this:

rrule(MONTHLY, dtstart = b).between(b, e, inc=True)

From these docs (http://labix.org/python-dateutil), it looks like calling rrule without specifying dtstart will use datetime.datetime.now() as the start point for the sequence that you're later applying between to. That's why your values begin at 2009-03-06.

DNS