Below snippet is used to increase the date by 1.
new_date = input_date + timedelta(1)
Find the below working application.
increase_date_by_1.py
from datetime import datetime, timedelta
def increase_date_by_n_days(input_date, days_to_increase):
new_date = input_date + timedelta(days_to_increase)
return new_date
input_date = datetime(1988, 6, 6)
new_date = increase_date_by_n_days(input_date, 1)
print('input_date -> ', input_date)
print('new_date -> ', new_date)
Output
input_date -> 1988-06-06 00:00:00 new_date -> 1988-06-07 00:00:00
Previous Next Home
No comments:
Post a Comment