Keeping the ISO week-year with a week number near New Year
Near New Year, the ISO week-year can differ from the calendar year. Report the week-year, week number and weekday together instead of attaching a week number to the year printed in the date.
The Thursday rule
ISO 8601 assigns each week to the year that contains its Thursday. Weeks run Monday to Sunday, so the Thursday is the fourth day, and a majority of the week's days fall in that year. This rule makes week 1 the week containing the first Thursday of January, which is the same as the week containing January 4. It also means the first days of January can sit in the last week of the previous year, and the last days of December can sit in week 1 of the next. The week-number tool applies the rule and returns the week-year as a separate output from the calendar year.
January 1, 2021
The date 2021-01-01 is a Friday. The Monday of its week is 2020-12-28, and the Thursday of that week is 2020-12-31, which lies in 2020. The week therefore belongs to week-year 2020, and since 2020 has 53 weeks, it is week 53. The tool returns week-year 2020, week 53 and weekday 5 for the Friday. A reader who sees a date in January 2021 with a week number of 53 may suspect a mistake, but the output is correct. The date 2021-01-03, a Sunday, is weekday 7 of the same week, and the next Monday, 2021-01-04, starts week 1 of 2021. Weekday 5 as a Friday also fixes the sequence: weekday 6 is Saturday 2021-01-02, so the three January days in that week all report week-year 2020 and week 53.
December 31, 2018
The date 2018-12-31 is a Monday. The Thursday of its week is 2019-01-03, which lies in 2019, so the week belongs to week-year 2019. It is the first week of that year, because it holds the first Thursday of 2019. The tool returns week-year 2019, week 1 and weekday 1. This is the mirror of the 2021 case. One date shows a January day in the previous week-year, and the other shows a December day in the next. If a report prints 2018-W01 for this date, the week-year was dropped, and the label points to January 2018. The date is also a clean illustration of why year-end reports show odd results: a sales total for the week ending Sunday 2019-01-06 is a week 1 total, even though one of its days is in the previous calendar year.
A December date in a 53-week year
Not every late-December date moves into the next week-year. For 2026, December 28 is a Monday and starts week 53 of 2026. The date 2026-12-31 is a Thursday and still belongs to week-year 2026, week 53 and weekday 4. The next day, 2027-01-01, is a Friday that falls in the same week, so it also has week-year 2026, week 53 and weekday 5. The boundary therefore changes from year to year, and one rule for all years, such as treating the last days of December as week 1, is wrong in some of them.
A further boundary: December 30, 2024
The date 2024-12-30 is a Monday. The Thursday of its week is 2025-01-02, so the week belongs to 2025 and is its week 1. The tool returns week-year 2025, week 1 and weekday 1. That date lies two days before the end of the calendar year, and a spreadsheet that takes the year from the date and the week from a week function can pair 2024 with week 1, a combination that names no valid week. Testing a handful of late-December and early-January dates in each system is the quickest way to catch it.
Weekday completes the identifier
A week-year and a week number identify a week of seven dates, not a single day. A receiving field that asks for a full week date, such as 2020-W53-5, needs the weekday too. The converter uses Monday as weekday 1 and Sunday as weekday 7, which differs from systems that number Sunday as 0 or 1. If the weekday is missing, a common default is Monday, but that choice should be stated. The reverse tool takes all three fields and returns the calendar date, so it can restore the day for the boundary examples above.
Where mismatches come from
Most boundary bugs come from three sources. One is combining the calendar year with the ISO week number. Another is using a week function with a different definition, for example one that numbers the week containing January 1 as week 1. The third is hard-coding 52 weeks per year. The first shows up on January 1 to 3 and on December 29 to 31 in some years. Test the five dates in this section, 2018-12-31, 2021-01-01, 2024-12-30, 2026-12-31 and 2027-01-01, and compare each triple with the tool before trusting a table. A system that returns 2018-W53 or 2024-W01 for any of them is combining the calendar year with the week number, and the fix is to switch to its ISO week-year field. Many libraries offer both fields under similar names, so read the documentation closely.
Turning the triples back into dates
The reverse converter is the natural partner for the five dates above. The triple (2020, 53, 5) returns 2021-01-01, (2025, 1, 1) returns 2024-12-30 and (2026, 53, 5) returns 2027-01-01. Each reverse result reproduces the date that produced the triple, which confirms that no field was lost. A table can run this loop automatically: convert each date forward, convert the triple back, and flag any row where the final date differs from the first. That test is cheap, and it finds mixed-up week-year columns that would otherwise reach a report.
What the result establishes
The result establishes the ISO week-year, week and weekday of the entered date under the ISO 8601 rule. It does not say how another organization numbers weeks, which fiscal calendar applies or how a date should be reported to an agency. Some fiscal and retail calendars have their own week rules, including 4-4-5 patterns, so a week number from them cannot be compared directly. Keep the date itself in any record that matters, and treat the week triple as a derived label. When a report must show a week label, print the week-year in the same format as the week, as in 2020-W53, so the reader never has to infer the year from the surrounding dates or guess which convention produced the label.
Reproduce the checks
January date in the prior week-year
Open the Week Number Calculator and enter:
- Calendar date
2021-01-01
Expected output:
Week year
2020Week
53Weekday
5The Friday remains in the preceding ISO week-year.
December date in the next week-year
Open the Week Number Calculator and enter:
- Calendar date
2018-12-31
Expected output:
Week year
2019Week
1Weekday
1The Monday begins the next ISO week-year.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08