DAYS Function in ONLYOFFICE: Date Difference, Negative Results and Leap Years
Calculate signed calendar-day differences in ONLYOFFICE with leap-year fixtures, date-entry safety, deadline reporting and troubleshooting.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in ONLYOFFICE Spreadsheet Editor. How formula examples are checked
Quick answer
DAYS(end_date,start_date) calculates the number of calendar days between two dates. The order is easy to reverse: the ending date comes first. To find the signed distance between 1 March and 28 February in a leap year, enter:
=DAYS(DATE(2024,3,1),DATE(2024,2,28))
Independently expected result: 2 (2024 has 29 February). Reversing the arguments is expected to produce −2, not an absolute value. The ONLYOFFICE DAYS function documentation confirms the argument order; the numeric outcomes are independently calculated predictions and were not observed in ONLYOFFICE.
Syntax, parameter order and type guidance
=DAYS(end_date, start_date)
| Parameter | Required | Meaning | Omission default |
|---|---|---|---|
end_date |
Yes | End of the interval, ideally a valid typed date or DATE(...) expression |
No default documented |
start_date |
Yes | Beginning of the interval, ideally a valid typed date or DATE(...) expression |
No default documented |
Neither parameter is optional. In the English help they are written in this order; commas separate the two arguments. The official ONLYOFFICE page describes dates but does not specify invalid input coercion, detailed time-of-day truncation, exact error-code outcomes, or minimum supported edition. In particular, the comprehensive text-date parsing and #VALUE!/#NUM! rules in Excel’s DAYS documentation are not automatically verified for ONLYOFFICE.
Reproduce a calendar-day fixture in a blank sheet
Enter headers in A1:D1: End date, Start date, DAYS result, Comment. Enter A2:B12 as the DATE(...) expressions below rather than importing localized date strings. In C2 type =DAYS(A2,B2) and fill through C12. Set C2:C12 to Number/General to avoid displaying integer differences as dates.
| Row | A: End date | B: Start date | Expected DAYS(A,B) |
What this checks |
|---|---|---|---|---|
| 2 | =DATE(2024,3,1) |
=DATE(2024,2,28) |
2 | Leap-day crossing |
| 3 | =DATE(2025,3,1) |
=DATE(2025,2,28) |
1 | Non-leap February |
| 4 | =DATE(2025,1,1) |
=DATE(2024,12,31) |
1 | Year boundary |
| 5 | =DATE(2026,10,11) |
=DATE(2026,10,11) |
0 | Same-day interval |
| 6 | =DATE(2026,10,1) |
=DATE(2026,10,11) |
−10 | Negative result |
| 7 | =DATE(2026,12,31) |
=DATE(2026,1,1) |
364 | Ordinary 365-day year excluding start |
| 8 | =DATE(2024,12,31) |
=DATE(2024,1,1) |
365 | Leap-year 366 days excluding start |
| 9 | =DATE(2020,3,1) |
=DATE(2020,2,29) |
1 | Leap-day input |
| 10 | =DATE(2024,2,28) |
=DATE(2024,3,1) |
−2 | Reversed leap interval |
| 11 | =DATE(2026,1,15) |
=DATE(2025,12,15) |
31 | Crossing to a later month |
| 12 | =DATE(2026,10,11) |
=DATE(2026,10,1) |
10 | A positive ten-day interval |
Every expected C-column value was computed using Python’s standard-library datetime.date subtraction; the provided CSV repeats the dates and expected outcomes. No ONLYOFFICE output was observed. DAY counts here refer to elapsed calendar-day boundaries, not business days: a weekend still contributes to a signed date difference.
Common workflows with exact, checkable decisions
1. Invoice aging. Assume A2 holds a due date, and B1 holds a dated reporting snapshot. =DAYS($B$1,A2) gives days past due when positive and days remaining when negative. If A2 is 2026-10-01 and B1 is 2026-10-11, independently expect 10 overdue days. To avoid losing sign, don’t wrap the result in ABS unless that is intentionally your business rule.
2. A rolling countdown. =DAYS(DATE(2026,12,31),TODAY()) means year-end date minus current date. If calculation occurs on an illustrative 2026-10-11, independently expect 81; on any later day the expected value differs. TODAY’s result and clock source were not natively tested. For stable testing, substitute =DATE(2026,10,11) for TODAY().
3. Days from first to last activity. If A2 is a start date and B2 is an end date, =DAYS(B2,A2) is an elapsed span. If the business wants to count both start and end calendar dates as inclusive days, use =DAYS(B2,A2)+1 only when end is not before start. Explain whether inclusive counting is actually required.
4. Overdue label. If A2 is a due date and B1 is a fixed report date: =IF(A2="","",IF(DAYS($B$1,A2)>0,"Overdue","Not overdue")). This treats a due date today as not overdue and preserves an empty date row. Validate how your imported workbook represents blanks.
5. Calculate a date interval before grouping by months. =DAYS(DATE(2024,3,1),DATE(2024,2,28)) is 2, not “one month”. DAYS gives calendar-day differences, while MONTH and YEAR extract components. It does not return complete months or fractional years.
6. Business-day exception. To count weekdays while excluding Saturday and Sunday, consider the separately documented NETWORKDAYS, not DAYS. Never label DAYS output as “working days” without adjusting for weekends, holidays and the approved work calendar.
Mistakes and diagnostic steps
| Symptom | Diagnosis and safer approach |
|---|---|
| Negative value where a positive one was expected | Arguments are reversed. Official order is end_date,start_date. Negative values can also be meaningful as “not yet due”. |
| Off-by-one when counting dates | DAYS measures between dates. Inclusive calendar-date counting is an explicit +1 business decision when the interval is forward. |
| Date appears instead of a number | Change result cell’s display format to Number/General; don’t replace the formula. |
| Confusion over 2024 February | 2024 is a leap year; 28 Feb to 1 Mar is two days. Compare with a non-leap year control. |
| Date text parses differently after copy/paste | Enter DATE(year,month,day) values. Text parsing and ambiguous month/day ordering depend on locale and input pathway. |
| Unexpected results in files imported from another program | Inspect 1904 date system settings and whether cells are actual dates or text. |
DAYS reports an error for a malformed date |
The ONLYOFFICE DAYS help page does not publish error-code behaviour for invalid inputs. Record the exact editor build and observed error before writing a claim. |
| The answer should exclude weekends | Use a verified business-day function such as NETWORKDAYS; DAYS is calendar-day subtraction. |
Compatibility without overclaiming
Excel’s DAYS page has the same named arguments and order. It additionally gives specific behaviour for text inputs, numeric dates, and invalid data, but those implementation details were not tested against ONLYOFFICE. The ONLYOFFICE reference does not name versions or release minimums; the Desktop and Docs release streams are distinct. Date serial representations may differ under the documented 1904 setting. Portable examples in this guide use explicit DATE(...) arguments and the common interval definition rather than fragile regional text date literals.
Scope, versions, locale and reproduction rules
The Insert Functions guide documents English formula examples with an = prefix, function names and commas between arguments. The Advanced Settings guide documents Formula Language, Region, and a workbook 1904 date system option. If your interface uses another formula language or locale, check the actual function picker and pasted formula separators; do not assume the English spelling/display carries over. The 1904 system can change underlying date serials when transferring files; prefer DATE(year,month,day) for explicit-date examples, and verify workbook settings when importing.
Related verified vendor pages
Official reference and verification
- ONLYOFFICE Spreadsheet Editor — function documentation
NETWORKDAYS- Desktop Editors changelog
- Docs 10.0 announcement
- Insert Functions guide
- Advanced Settings guide
- DATE
Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in ONLYOFFICE Spreadsheet Editor.
- No genuine ONLYOFFICE Spreadsheet Editor screenshots are included; this guide does not use mock application images.