how to build a list of mx.DateTime objects from a start and end date?

Christos TZOTZIOY Georgiou tzot at
Tue Sep 16 23:25:17 CEST 2003

On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that
python at might have written:

>I want to make a list of mx.DateTime objects that cover all the monthly
>intervals between two points.  For example:
>>>> import mx.DateTime
>>>> nov1999 = mx.DateTime.Date(1999, 11)
>>>> mar2003 = mx.DateTime.Date(2003, 3)
>>>> alldates = mk_list(startdate=nov1999, enddate=mar2003)
>>>> alldates
>[ ... a bunch of mx.DateTime objects including and between the startdate
>and enddate ...]
>How would I do something like this?

I'm not familiar with the exact names of the mx functions, but what I
would do, would be:

create an empty list
set an mx.DateTime object to the start date
while the mx.DateTime is less or equal to the end date:
 append it to the list, add one day to it

Add some parentheses and you got the python code :)
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.

More information about the Python-list mailing list