datetime: the date of the day one month ago...how?

gabor gabor at nekomancer.net
Wed Apr 12 07:02:07 EDT 2006


hi,

i'm trying to get the date of the day one month ago.

for example:

today = 	12.apr.2006
one-month-ago = 12.mar.2006

so:

one-month-ago(12.apr.2006) = 12.mar.2006

of course sometimes it gets more complicated, like:

one-month-ago(31.mar.2006)

or

one-month-ago(1.jan.2006)

the datetime.timedelta objects only work with hours or days or weeks, 
not month (i understand why)...

but is there a way to calculate this in python?

i really don't want to calculate it by myself :-))

thanks,
gabor



More information about the Python-list mailing list