How to add months to a date (datetime object)?
abiodun.ogunmolu at gmail.com
abiodun.ogunmolu at gmail.com
Wed Nov 22 04:44:52 EST 2017
How about this...
from dateutil.relativedelta import relativedelta
myDate = datetime.date.today() + relativedelta(months=3)
On Sunday, March 15, 2009 at 5:28:24 PM UTC, tin... at isbd.co.uk wrote:
> 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