WEEKSINYEAR Function (LibreOffice Calc)
The WEEKSINYEAR function returns the number of ISO weeks in the year of a given date. It is essential for ISO-compliant calendars, reporting, scheduling, and week-based planning.
Compatibility
▾| Excel | ✖ |
| Gnumeric | ✔ |
| Google_sheets | ✖ |
| Libreoffice | ✔ |
| Numbers | ✖ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the WEEKSINYEAR Function Does ▾
- Returns 52 or 53 depending on the ISO week calendar
- Uses ISO 8601 rules
- Accepts dates, serial numbers, and DATEVALUE
- Ideal for calendar generation and reporting
It is designed to be simple, accurate, and ISO‑compliant.
Syntax ▾
WEEKSINYEAR(date_value)
Arguments
- date_value:
A date, datetime, or serial number.
Basic Examples ▾
Weeks in the year of a given date
=WEEKSINYEAR("2024-03-15")
Weeks in the current year
=WEEKSINYEAR(TODAY())
Weeks in the year stored in a cell
=WEEKSINYEAR(A1)
Advanced Examples ▾
Determine if a year has 53 ISO weeks
=WEEKSINYEAR(DATE(A1;1;1)) = 53
Weeks in the year extracted from text
=WEEKSINYEAR(DATEVALUE(A1))
Weeks in the year from imported CSV timestamp
=WEEKSINYEAR(DATEVALUE(LEFT(A1;10)))
Weeks in the year from Excel serial date stored as text
=WEEKSINYEAR(DATE(1899;12;30)+VALUE(A1))
Build a label like “2024 has 52 ISO weeks”
=YEAR(A1) & " has " & WEEKSINYEAR(A1) & " ISO weeks"
Determine if a date falls in the last ISO week of the year
=ISOWEEKNUM(A1) = WEEKSINYEAR(A1)
ISO Week Rules (Summary) ▾
- ISO week starts on Monday
- Week 1 is the week containing January 4
- ISO years can have 52 or 53 weeks
- Years with 53 weeks occur when:
- Jan 1 is a Thursday, or
- It is a leap year and Jan 1 is a Wednesday
Edge Cases and Behavior Details ▾
WEEKSINYEAR returns 52 or 53
Accepts:
- Real dates
- Serial numbers
- DATEVALUE outputs
- ISO date strings
Invalid text → Err:502
Behavior details
- Time components ignored
- ISO rules strictly applied
- Works for all Gregorian years
WEEKSINYEAR of an error → error propagates
Common Errors and Fixes ▾
Err:502 — Invalid argument
Cause:
- Text not recognized as a date
- Non-numeric values
Fix:
- Wrap with DATEVALUE
- Clean text with TRIM or SUBSTITUTE
Wrong week count expected
Cause:
- Confusing ISO weeks with Excel/US week numbering
Fix:
- Use ISOWEEKNUM and WEEKSINYEAR together
Unexpected result from serial numbers
Fix:
- Convert with DATE(1899;12;30)+VALUE(A1)
Best Practices ▾
- Use WEEKSINYEAR for ISO-compliant calendars
- Use ISOWEEKNUM for week numbering
- Normalize text dates with DATEVALUE
- Use WEEKSINYEAR for reporting and scheduling dashboards
- Use WEEKSINYEAR to validate week-based datasets
WEEKSINYEAR is your ISO week‑count engine — perfect for calendar generation, reporting, and any workflow that depends on ISO week structures.
Related Patterns and Alternatives ▾
- Use ISOWEEKNUM for ISO week numbering
- Use WEEKNUM for locale-based week numbering
- Use WEEKS for week intervals
- Use DAYSINYEAR for year length
- Use DATEVALUE for text conversion
By mastering WEEKSINYEAR and its companion functions, you can build powerful, ISO‑compliant, and fully structured week‑based workflows in LibreOffice Calc.