Days in month
Write a function that returns the number of days in a given month and year, correctly handling leap years.
Days Between Dates
Write a function that returns the number of days between two given dates.
Add Days to Date
Given a date in YYYY-MM-DD format and an integer number of days, return the resulting date in the same format.
Business days between
Calculate the number of business days (Mon-Fri) between two dates, inclusive of both endpoints.
Week Number ISO
Given a date, return its ISO 8601 week number (1–53) without using datetime.isocalendar().
Duration Human Readable
Write a function that turns a number of seconds into a human-readable duration like '2 hours, 1 minute'.
Julian Day Number Converter
Implement two functions to convert between Gregorian calendar dates and Julian Day Numbers using a standard formula.
Showing 7 challenges · Datetime & Time Calculations
Datetime & Time Calculations — Python coding challenges
What you will find here
This page lists datetime & time calculations challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.