Calculating future dates

Irmen de Jong irmen.NOSPAM at xs4all.nl
Thu Feb 1 19:55:49 EST 2007


Toine wrote:
> Hello,
> 
> I'm new to Python so please bare with me...
> 
> I need to calculate a date that is exactly 31 days from the current
> date in YYYY-MM-DD format. I know that date.today() returns the
> current date, but how can I add 31 days to this result? I'm sure this
> task is simple, but I haven't been able to figure it out.

 >>> import datetime
 >>> print datetime.date.today()+datetime.timedelta(days=31)
2007-03-05
 >>>


---Irmen



More information about the Python-list mailing list