Add months to datetime in python
1 2 3 4 5 import datetime from dateutil.relativedelta import relativedelta your_datetime = datetime.datetime.now() your_datetime + relativedelta(months=1) # adds one month That function clips the overflowing day of the months: 1 2 3 4 5 6 7 8 9 10 >>> datetime(2021, 1, 28) + relativedelta(months=1) datetime.datetime(2021, 2, 28, 0, 0) >>> datetime(2021, 1, 29) + relativedelta(months=1) datetime.datetime(2021, 2, 28, 0, 0) >>> datetime(2021, 1, 30) + relativedelta(months=1) datetime.datetime(2021, 2, 28, 0, 0) >>> datetime(2021, 1, 31) + relativedelta(months=1) datetime....