Add Two Weeks to a Date
Intermediate · Write the code · from Python datetime: Dates, Times, Timezones, and Calculations
From the lesson: Python datetime: Dates, Times, Timezones, and Calculations
Think about your phone. It shows the current time, tracks your calendar events, and reminds you about birthdays. Behind the scenes, all of that runs on date and time calculations.
Read the lessonStarting from date(2024, 6, 15), add 14 days using timedelta. Print the result in the default format (YYYY-MM-DD).
from datetime import date, timedelta
start = date(2024, 6, 15)
# Add 14 days and print
More datetime exercises
- Create and Display a DateBeginner
- Calculate Days Between DatesBeginner
- Parse a Date StringIntermediate
- Predict the Date OutputIntermediate
- Sort Events by DateAdvanced
All Python exercises · 50 practice problems · Standard Library Essentials quiz