Adding days to a date in Python Adding days to a date in Python python python

Adding days to a date in Python


The previous answers are correct but it's generally a better practice to do:

import datetime

Then you'll have, using datetime.timedelta:

date_1 = datetime.datetime.strptime(start_date, "%m/%d/%y")end_date = date_1 + datetime.timedelta(days=10)


Import timedelta and date first.

from datetime import timedelta, date

And date.today() will return today's datetime, may be you want

EndDate = date.today() + timedelta(days=10)


If you happen to already be using pandas, you can save a little space by not specifying the format:

import pandas as pdstartdate = "10/10/2011"enddate = pd.to_datetime(startdate) + pd.DateOffset(days=5)


matomo