You told me to think how to get the first day of the previous month, well how to know if the previous month is 28, 29, 30 or 31 days?
Find the first day of the *current* month, and then subtract one day (use the timedelta object). You'll end up with the last day of the previous month as a date/datetime object.
-tkc -- http://mail.python.org/mailman/listinfo/python-list