Hussein B wrote:

I'm creating a report that is supposed to harvest the data for the
previous month.
So I need a way to get the first day and the last day of the previous
month.
Would you please tell me how to do this?
Thanks in advance.

dateutil can do this and much, much more.


>>> from datetime import date
>>> from dateutil.relativedelta import relativedelta
>>> today = date.today()
>>> d = today - relativedelta(months=1)
>>> date(d.year, d.month, 1)
datetime.date(2008, 12, 1)
>>> date(today.year, today.month, 1) - relativedelta(days=1)
datetime.date(2008, 12, 31)
>>>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to