Add weeks to a date
We can get a future date from the current date by adding days or weeks. To get the past date, substract the days or weeks.
Python: 3.0    Anurag Rana    13 Jul 2021   0
Login to upvote
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from datetime import timedelta, date

current_date = date.today()
# add days
future_date = current_date + timedelta(days = 90)
# add weeks
future_date2 = current_date + timedelta(weeks = 15)

# past date
past_date = current_date - timedelta(days = 180)
# past days by weeks
past_date = current_date - timedelta(weeks = 12)
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com