Find the ISO week number and corresponding year for any calendar date.
The ISO 8601 standard defines week 01 as the week containing the first Thursday of the year, with weeks starting on Monday. To calculate the week number, we find the Thursday of the week containing the input date, determine how many days that Thursday is from January 4th (which always falls in ISO week 1), then divide by 7 and add 1. If the computed week exceeds 52, it may belong to week 1 of the following year. Similarly, early January dates can belong to the last week of the previous year. This ensures every year has either 52 or 53 complete weeks.
What is the ISO week number for January 1st?
It depends on what day of the week January 1st falls on. If January 1st is a Monday, Tuesday, Wednesday, or Thursday, it belongs to week 1. If it falls on Friday, Saturday, or Sunday, it belongs to the last week (52 or 53) of the previous ISO year.
Why does the ISO week year sometimes differ from the calendar year?
Because ISO week 1 must contain the first Thursday of the year, dates at the very start or end of a calendar year can belong to a different ISO year. For example, December 31st might fall in week 1 of the next year, or January 1st might fall in the last week of the previous year.
How many weeks are in an ISO year?
An ISO year has either 52 or 53 weeks. A long year (53 weeks) occurs when the year starts on a Thursday or is a leap year starting on a Wednesday. This follows from the rule that week 1 always contains January 4th.