Date calculations

How to Calculate the ISO Week Number From a Date

Find an ISO week number and week-year using Monday-based weeks, the first-Thursday rule, and year-boundary examples. This guide explains the reasoning, not just the keystrokes.

Published · Updated · 5 min read

Use the ISO week definition

ISO weeks start Monday and run through Sunday. Week 1 is the week containing January 4, equivalently the year's first Thursday. The associated week-year can differ from the calendar year near New Year.

Always report both values, such as 2026-W01. Writing week 1 alone can be ambiguous, and US Sunday-based week conventions can produce another result.

Use the Thursday method

Take the date's Monday-based weekday, move to the Thursday in the same ISO week, and use that Thursday's calendar year as the ISO week-year. Then count seven-day blocks from the first ISO Thursday.

This method works because every ISO week has one Thursday and week 1 contains the year's first Thursday. Date libraries still need careful local or UTC handling to avoid midnight shifts.

Three complete examples

Input: Monday January 4, 2021. Formula: week containing January 4 is week 1. Calculation: its Thursday is January 7, 2021. Result: 2021-W01. Interpretation: Monday begins the ISO week.

Input: Friday January 1, 2021. Formula: assign by same-week Thursday. Calculation: Thursday is December 31, 2020. Result: 2020-W53. Interpretation: calendar year and ISO week-year differ.

Input: Monday January 3, 2022. Formula: locate first ISO week. Calculation: the week's Thursday is January 6, 2022. Result: 2022-W01. Interpretation: this date begins the first ISO week.

Recognize 52- and 53-week years

An ISO year usually has 52 weeks and sometimes 53. A year has week 53 when its layout supplies the required extra Thursday, commonly when January 1 is Thursday or in certain leap-year arrangements.

Never assume December 31 is in the final week of its calendar year. Calculate its week-year explicitly.

Avoid convention mismatches

Spreadsheet functions, programming libraries, payroll systems, and national calendars may use Sunday starts, partial week 1, or locale-specific numbering. Select the ISO option explicitly.

Ordinal day, calendar week, fiscal week, and week of month are different concepts. State the standard whenever data crosses systems.

Verify boundary dates

Test December 29 through January 4 because most mistakes appear there. Dates seven days apart should share weekday and normally differ by one ISO week, with rollover handled at the week-year boundary.

Use date-only arithmetic consistently. Parsing a date as UTC and displaying in a western local zone can shift it to the previous calendar day.

The ISO weekday number is Monday=1 through Sunday=7. Converting a Sunday-based programming value requires care; treating Sunday as zero without adjustment can move the calculated Thursday into the wrong week.

Week 1 always contains at least four days of the new calendar year. This majority rule is another way to remember the first-Thursday definition. The days before week 1 belong to the previous ISO week-year.

A date such as December 31 can belong to week 1 of the following ISO year. Therefore grouping records by calendar year first and week number second can split one ISO week. Group by week-year and week together.

When importing spreadsheets, confirm whether a function uses ISO mode. Similar function names may use different return types. Test a known boundary such as 2021-01-01, expected 2020-W53, before processing a large data set.

Week numbers are useful for reporting but hide the exact date range. Include the Monday start date or a clear year-week label in exports. This reduces ambiguity when colleagues use other calendar conventions.

Use the Week Number Calculator

Enter a date to see ISO weekday, ISO week number, and ISO week-year. Keep the week-year with exported results.

The tool does not calculate retail 4-4-5 calendars, employer pay periods, or jurisdiction-specific week numbering unless those exactly match ISO rules.

A manual algorithm can convert Sunday to ISO weekday 7, compute the date's Thursday, locate the Thursday of week 1, and divide the day difference by seven before adding one. Use calendar-date arithmetic rather than milliseconds when local daylight-saving transitions could make a nominal day shorter or longer. The week result depends on dates, not elapsed hours between midnights.

Consider December 28. It always belongs to the final ISO week of its ISO year, making it a useful anchor for determining whether that year ends with week 52 or 53. January 4 always belongs to week 1. These invariants help diagnose code that assigns every January date to the new week-year or every December date to the old one.

Database storage should keep either the original date or a pair of ISO week-year and two-digit week. A bare integer such as 1 or 53 is not a unique period. When sorting text, zero-padding W01 through W09 maintains natural order. For reporting, also expose the Monday–Sunday date range so readers can verify the intended period.

Fiscal calendars may deliberately contain 53 weeks using rules unrelated to ISO. Retail 4-4-5 calendars group weeks into accounting periods and sometimes add a leap week. Do not relabel such data as ISO merely because both use Monday or Sunday blocks. Name the calendar owner and version in exports and dashboards.

For quality assurance, create boundary fixtures across ordinary years, leap years, years beginning Thursday, and years beginning Friday. Verify 2021-01-01 as 2020-W53 and 2021-01-04 as 2021-W01. Also test local parsing so an ISO date string does not display as the previous date and therefore receive the wrong week.

Worked audit: Sunday January 3, 2021 has ISO weekday 7. Its same-week Thursday is December 31, 2020, so its week-year is 2020. That Thursday lies in the 53rd ISO week, producing 2020-W53. The next day, Monday January 4, starts 2021-W01. This adjacent pair is a strong boundary test because a calendar-year-only implementation often labels both dates 2021. For every result, retain original date, ISO weekday, two-digit week, and week-year. Verify January 4 maps to W01, December 28 maps to the final week, Monday begins a new week, and date parsing has not shifted through UTC conversion. Compare spreadsheet or library output using its explicit ISO option. If the business uses fiscal, retail, broadcast, or locale weeks, document that separate calendar rather than modifying ISO rules while keeping the ISO label. A week identifier is reliable only when its standard and year are both visible.

Frequently asked questions

Does an ISO week start Sunday?

No, it starts Monday.

What defines ISO week 1?

It is the week containing January 4, or the year's first Thursday.

Can January 1 belong to the previous week-year?

Yes, as January 1, 2021 belongs to 2020-W53.

Can an ISO year have 53 weeks?

Yes, when its weekday layout includes an extra ISO week.

Why include the week-year?

It can differ from the calendar year near New Year.

Sources

References used to support definitions and interpretation in this guide.

  1. ISO — Date and time format
  2. MDN — Date