Adding days to date in Python

Today we will see how to add days to a date object. Using the datetime.timedelta() method of datetime module you can add any number of days to a date object. Here is an example.

## Adding days to date in Python
import datetime

## Date object
date_original = datetime.date(2019, 7, 20)

## Days to add
days_to_add = 16

## Add
date_new = date_original + datetime.timedelta(days_to_add)

print("\n Original Date: ", date_original, "\n")
print("\n New Date: ", date_new, "\n")
Adding days to date object in Python

Reference

More Tips


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.