Python Date and Time Mastery: Managing Temporal Data

Operations with DatesOperations with Dates

Now that you have understood what datetime objects are and how you can transform them, we can introduce the timedelta() function. timedelta() allows you to alter your dates by adding a delta to your dates (days, months, ecc..). We will also show how easy it is to find the difference between two dates.

Task

  1. Import the datetime library with the timedelta module;
  2. Find the difference between two dates;
  3. Add 30 days to the date1 variable.

Everything was clear?

Section 1. Chapter 5

Start learning today and achieve
coding mastery

  • Master Python, SQL, JavaScript & more.
  • Learn with Step-by-Step Lessons.
  • Get Ready for Real-World Projects.
  • Earn a Certificate Upon Completion.