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

Hussein B hubaghdadi at gmail.com
Tue Jan 20 10:32:06 EST 2009


On Jan 20, 5:04 pm, Carsten Haese <carsten.ha... at gmail.com> wrote:
> 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 Haesehttp://informixdb.sourceforge.net

Thanks all for the reply.
Yes, I prefer to use the standard library.
Talking about the third step:
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?
I'm new to Python, so forgive my questions.



More information about the Python-list mailing list