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

Tim Chase python.list at tim.thechases.com
Tue Jan 20 16:47:16 CET 2009


> 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






More information about the Python-list mailing list