Home > Enterprise >  How do I take end date as 11 months ahead of start date in the datetime format in Python?
How do I take end date as 11 months ahead of start date in the datetime format in Python?

Time:10-16

I am taking start date as user input in the datetime format in python. Using the start date, I want to take end date as 11 months from start date.

start_date= month_dt
end_date = 

Here, month_dt is taken in taken as user input in the datetime format, e.g. 2020-01-01 . How do I take end_date as 11 months ahead of the start date?

CodePudding user response:

import datetime
from dateutil.relativedelta import relativedelta


print(datetime.date.today() - relativedelta(months= 11))

Current date reduced by 11 months

  • Related