1.datetime, date, time, and timedelta
date holds a calendar day, time holds a clock reading with no day, datetime combines both into one point in time, and timedelta holds a duration you can add to or subtract from any of the other three.
Key features
- date(year, month, day) has no clock time — comparing two dates ignores time of day entirely
- time(hour, minute, second) has no calendar day — it cannot be placed on a timeline by itself
- datetime(year, month, day, hour, minute, second) is the only one of the three that is a specific instant
- timedelta represents a span, not a point — datetime + timedelta gives a datetime, but datetime + datetime is a TypeError
- datetime.combine(a_date, a_time) builds a datetime out of a separate date and time value
The four datetime.* types — what each one holds
- date and time, separately
- date(2026, 8, 21) — a day, no clock reading
- time(9, 30) — a clock reading, no day
- Neither alone is a point on a timeline
- datetime, combined
- datetime(2026, 8, 21, 9, 30) — both at once
- datetime.combine(d, t) builds one from the other two
- Only this form is a specific instant you can order or diff precisely
Command
from datetime import date, time, datetime, timedelta
date(2026, 8, 21) # calendar day only
time(9, 30) # clock reading only
datetime(2026, 8, 21, 9, 30) # both
datetime.combine(date(2026, 8, 21), time(9, 30))
date(2026, 8, 21) + timedelta(days=10) # -> date(2026, 8, 31)date is a day, time is a clock reading, datetime is both together as one instant, and timedelta is a duration you add to or subtract from any of the first three — but never mix a bare date with a datetime in arithmetic.