Python Practice › Datetime Programs › Program 5
Days between two dates
Write a Python program to count the days between two dates.
Input
2026-01-26 and 2026-08-15
Output
201
Approach
- Subtract dates; read
.days.
Solution
from datetime import date print((date(2026, 8, 15) - date(2026, 1, 26)).days)Output
201
Learn the concept
New to this topic? Read the lesson, then come back.