date.weekday / isoweekday

Both count from Monday; they differ only by one. Neither matches strftime %w, which counts from Sunday = 0.

date methodPython 2.3+Live demo
Common call
d.weekday() >= 5 # weekend
Returns
True on Saturday and Sunday
Replaces
calendar.weekday(y, m, d)
Watch out
weekday() is a method (parentheses), unlike year/month/day
d.weekday()
→ int

Demo

Live evaluation
The same day through all four conventions.
Try:
Inputs
whenstrYYYY-MM-DD
Code
from datetime import date
d = date.fromisoformat('2026-09-29')
(d.weekday(), d.isoweekday(), d.strftime('%w'), d.strftime('%A'))
Result
(1, 2, '2', 'Tuesday')

Sunday is the case where they disagree most: weekday() 6, isoweekday() 7, and strftime("%w") "0" — a string, counting from Sunday.

Common patterns

Is it a weekend?
Saturday and Sunday are 5 and 6.
is_weekend = d.weekday() >= 5
Monday of the same week
Subtract the weekday.
from datetime import timedelta
monday = d - timedelta(days=d.weekday())
Next Friday (or today if Friday)
Modular arithmetic on weekday().
from datetime import timedelta
friday = d + timedelta(days=(4 - d.weekday()) % 7)

Examples

1. A Tuesday
from datetime import date d = date(2026, 9, 29) (d.weekday(), d.isoweekday())
Returns
(1, 2)
2. A Sunday
from datetime import date d = date(2026, 9, 27) (d.weekday(), d.isoweekday())
Returns
(6, 7)
3. Weekend test
from datetime import date date(2026, 9, 27).weekday() >= 5
Returns
True
4. Monday of the week
from datetime import date, timedelta d = date(2026, 9, 29) d - timedelta(days=d.weekday())
Returns
datetime.date(2026, 9, 28)
5. The day name
from datetime import date date(2026, 9, 29).strftime('%A')
Returns
'Tuesday'

Pitfalls

1. Forgetting the parentheses
weekday is a method; without () you get the bound method, which is never equal to a number.
d.weekday == 1
from datetime import date
date(2026, 9, 29).weekday == 1
False
d.weekday() == 1
from datetime import date
date(2026, 9, 29).weekday() == 1
True
2. Mixing up the conventions
Indexing a Sunday-first list with weekday() is off by one day. Match the list to the method.
Sunday-first list
from datetime import date
['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date(2026, 9, 29).weekday()]
'Mon'
Monday-first list
from datetime import date
['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][date(2026, 9, 29).weekday()]
'Tue'

When to use

Use it
  • Weekend/business-day logic
  • Jumping to the start of a week
Reach for something else
  • Day names for display → strftime("%A") (locale-aware)
  • ISO week numbers → isocalendar()

Notes

CPython impl
weekday() is (toordinal() + 6) % 7; isoweekday() adds 1
Conventions
weekday 0–6 Mon–Sun · isoweekday 1–7 Mon–Sun · strftime %w 0–6 Sun–Sat · %u 1–7 Mon–Sun
Also on
datetime inherits both

FAQ

d.weekday() returns 0 for Monday up to 6 for Sunday; d.isoweekday() returns 1 to 7. For the name use d.strftime("%A").