Contact

WEEKS Function (OpenOffice Calc)

Date & Time Intermediate OpenOffice Calc

Count date intervals with WEEKS in Apache OpenOffice Calc. Compare whole weeks and calendar mode, including the verified New Year boundary limitation.

Verification status: Eight ordinary reference formulas were recalculated in Apache OpenOffice 4.1.16 on Linux x86-64, Build 9816, through generated native ODF and GUI hard recalculation. Saved identities, inputs and results were checked. The registered ORG.OPENOFFICE storage name was used; English-name availability is source-checked. How formula examples are checked

Quick answer: =WEEKS(DATE(2024;1;1);DATE(2024;1;15);0) returned 2 in the tested Apache OpenOffice 4.1.16 build.

Availability and version history

  • Introduced: First release not established; documented by OpenOffice.org 3.3.
  • Supported in: Apache OpenOffice 4.1.16; this is a verified release, not a final supported version.
  • Scope: Desktop Calc, English function names and semicolon-separated formulas.
  • Checked: October 14, 2026. Eight ordinary reference formulas were recalculated from generated ODF in 4.1.16 on Linux x86-64, Build 9816. Source and independent arithmetic were checked.

What WEEKS returns

WEEKS returns an integer interval between two dates. Mode 0 divides the elapsed day count by seven and truncates toward zero. Mode 1 uses a Monday-based calendar-week calculation, but its integer-division implementation has a New Year boundary limitation that matters for dates before the first Monday used by its calculation. Release implementation.

Syntax and arguments

WEEKS(StartDate;EndDate;Mode)
  • StartDate, EndDate: required date serials or date cells.
  • Mode: required integer. Use 0 for complete seven-day intervals or 1 for the calendar calculation. The implementation treats other modes as the interval branch; this guide recommends the documented choices.
  • All three arguments are required. Date inputs enter the add-in as integer serials.

Eight reproducible examples

The native column contains saved 4.1.16 results; independent references use high-precision arithmetic and the stated source rules. Values are shown to twelve decimal places where needed. Enter DATE expressions directly rather than locale-dependent date text.

The generated ODF uses ORG.OPENOFFICE.WEEKS, mapped to the English worksheet name WEEKS by the release function map. The saved operation was verified after recalculation.

Formula Native 4.1.16 result Independent reference
=WEEKS(DATE(2024;1;1);DATE(2024;1;15);0) 2 2
=WEEKS(DATE(2024;1;1);DATE(2024;1;14);0) 1 1
=WEEKS(DATE(2024;1;7);DATE(2024;1;8);0) 0 0
=WEEKS(DATE(2024;1;7);DATE(2024;1;8);1) 1 1
=WEEKS(DATE(2021;1;1);DATE(2021;1;4);1) 0 0
=WEEKS(DATE(2021;1;4);DATE(2021;1;11);1) 1 1
=WEEKS(DATE(2024;1;15);DATE(2024;1;1);0) -2 -2
=WEEKS(DATE(2023;12;25);DATE(2024;1;8);1) 2 2

Practical worksheet

January 1 to January 15, 2024 is 14 days, so Mode 0 gives 2. January 1 to January 14 is 13 days, so it gives 1. Reversing the 14-day interval gives −2. This is truncation toward zero, not rounding to the nearest week.

From Sunday January 7 to Monday January 8, 2024, Mode 0 gives 0 while Mode 1 gives 1. That pair crosses a Monday boundary even though only one day elapsed. Choose the definition before interpreting the result.

Advanced interpretation and checks

Calendar-mode limitation in the tested release: =WEEKS(DATE(2021;1;1);DATE(2021;1;4);1) returns 0, although the dates cross from Friday to the following Monday. The source subtracts a Monday anchor derived from January 4 and applies C++ integer division, which truncates a negative partial week toward zero. This is not a reliable general ISO week-boundary counter around that anchor.

For an explicitly Monday-based boundary count, enter =DATE(2021;1;1) in A2 and =DATE(2021;1;4) in B2. Then subtract the Monday at or before each date: =((B2-WEEKDAY(B2;2)+1)-(A2-WEEKDAY(A2;2)+1))/7. For January 1 to January 4, 2021, this calendar arithmetic gives 1. That alternative was independently calculated; it was not included in the native example fixture.

Boundaries and troubleshooting

Use Mode 0 when whole elapsed weeks are the actual requirement. Its negative partial intervals truncate toward zero, so −6 days gives 0 weeks, not −1. For Mode 1, keep the demonstrated New Year limitation visible and verify boundary dates before using the function in a reporting calendar.

The eight native calls use valid ordinary dates and Modes 0 or 1. Text dates, missing inputs, extreme dates and other modes were not executed. The ODF stored the registered ORG.OPENOFFICE function identity; no manual-entry or other-locale behavior is inferred.

Official evidence and checking scope

The generated ODF produced the informational load warning “Not all attributes could be read.” The sheet was hard-recalculated and saved separately. All eight ordinary function identities, inputs and results were reconciled; a stale SUM cache changed from 999999 to 3 and an uncached SUM returned 7. This establishes the stated examples, not every workbook style or invalid input. Other explanatory identities are independent calculations. The authoring-tool XLSX was not executed in OpenOffice, and its preview values are not the native results reported here.