ISO Week Number in Python
Updated: May 2026
Python's standard library handles ISO weeks natively. The isocalendar() method on date and datetime objects returns the ISO year, ISO week number, and ISO weekday in one call — correctly handling all year-boundary edge cases.
Free · No upload · 100% in-browser
The standard method: isocalendar()
Since Python 3.9, isocalendar() returns a named tuple IsoCalendarDate(year, week, weekday). In earlier versions it returns a plain tuple. Both work the same way.
The weekday field uses ISO numbering: 1 = Monday through 7 = Sunday. This is different from date.weekday(), which returns 0 for Monday, and from date.isoweekday(), which matches the ISO numbering (1–7).
Always use isocalendar().year rather than date.year when you need the ISO year. For December 31 and early January dates, these two values can differ by one.
Using strftime with %V and %G
The strftime format supports ISO week directives:
%V— ISO week number (01–53), Monday as first day.%G— ISO year (the year that owns the week — may differ from calendar year).%u— ISO weekday (1 = Monday, 7 = Sunday).%W— simple week number with Monday start but non-ISO week 1 definition — avoid for ISO work.%U— simple week number with Sunday start — not ISO.
Parsing an ISO week date string
To convert an ISO week string like "2026-W22-4" back to a date object:
date.fromisocalendar(year, week, day) is available since Python 3.8. It raises ValueError for invalid combinations, such as week 53 in a 52-week year.
Getting the Monday of an ISO week
To find the Monday (first day) of a given ISO year and week:
To get the full week range (Monday to Sunday):
Counting how many ISO weeks in a year
A year has 53 ISO weeks when December 28 belongs to week 53. December 28 is always in the last ISO week of the year: