How to get first/last day of the previous month?

Carsten Haese carsten.haese at gmail.com
Tue Jan 20 10:04:00 EST 2009


Hussein B wrote:
> Hey,
> 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.

In order to not deprive you of the sense of accomplishment from figuring
things out for yourself, I'll give you a couple of hints instead of
fully formed Python code:

1) Think about how you can find the first day of the *current* month.

2) Think about how you can get to the last day of the previous month
from there.

3) Think about how you can get to the first day of the previous month
from there.

Hope this helps,

--
Carsten Haese
http://informixdb.sourceforge.net



More information about the Python-list mailing list