Finding all time periods for a given interval within a date range
Chris Irish
chris.irish at libertydistribution.com
Wed Aug 4 17:31:43 EDT 2004
Robert Brewer wrote:
>Graeme Longman wrote:
>
>
>>I was wondering if anyone has written some Python code which
>>uses a start
>>date and end date and a given interval (day, month or year)
>>and outputs all
>>the time periods for that range and interval.
>>
>>For example you may wish to find all the months between the dates
>>'2004-02-14' and '2004-08-04'. You would maybe use a function
>>where you pass
>>in those starting and ending dates and the interval 'month'
>>and you'd get
>>back a list of those months. I guess you would need to year
>>part of the date
>>too, so ['2004-02', '2004-03', '2004-04', '2004-05',
>>'2004-06', '2004-07',
>>'2004-08']. If you had passed in 'day' as the interval then
>>you would be
>>given back a list of all the days in those months.
>>
>>
>
>You should also look into the mx.DateTime module it has all sorts of time functionality already built into it much better than the python time module. Have a look here
>
>http://www.egenix.com/files/python/mxDateTime.html
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040804/c631e601/attachment.html>
More information about the Python-list
mailing list