Days between two dates

EasyDatetime Programs · 5 of 20

Write a Python program to count the days between two dates.

Advertisement
Input
2026-01-26 and 2026-08-15
Output
201

Approach

  1. Subtract dates; read .days.

Solution

Python
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.

More datetime programs

← All 20 Datetime Programs

Leave a Comment