Subtracting days from date in Python

In my previous article, we have seen how to add days to a date object in python. Now we will see how to subtract days form date object using the datetime.timedelta() method. Here is an example.

## Subtracting days from date
import datetime

## Date object
date_original =, 7, 20)

## Days to subtract
days_to_sub = 387

## Subtract
date_new = date_original - datetime.timedelta(days_to_sub)

print("\n Original Date: ", date_original, "\n")
print("\n New Date: ", date_new, "\n")
Subtracting Days From Date In Python


2 thoughts on “Subtracting days from date in Python”

Leave your thoughts...

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