How to add months to a date (datetime object)?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Sun Mar 15 18:28:24 CET 2009


I have a date in the form of a datetime object and I want to add (for
example) three months to it.  At the moment I can't see any very
obvious way of doing this.  I need something like:-

    myDate = datetime.date.today()
    inc = datetime.timedelta(months=3)
    myDate += inc

but, of course, timedelta doesn't know about months. I had a look at
the calendar object but that didn't seem to help much.

-- 
Chris Green



More information about the Python-list mailing list