Calligra Sheets DAYSINMONTH Function: Month Lengths & Leap Years
Find the exact number of calendar days in a given month and year with Calligra Sheets DAYSINMONTH(year;month), including leap-year examples and validation limits.
Verification status: Consult the documentation and examples below. Native application testing has not been documented for this guide. How formula examples are checked
Quick answer
DAYSINMONTH returns the number of calendar days in a specified month of a specified year: 28, 29, 30 or 31 for valid Gregorian months. This Calligra-specific guide follows the official KDE function handbook, matching XML function definitions, and the pinned Calligra 26.08.2 implementation. [K1–K3]
Target and evidence status: Calligra 26.08.2, released October 8, 2026, with particular relevance to the Qt 6 / KDE Frameworks 6 application commonly distributed on Linux. Official material was checked on 2026-10-12. Testing disclosure: numerical example outputs below are expected values independently checked with Gregorian-calendar calculations and/or traced to source code; they were not observed in Calligra Sheets. The installed release, workbook settings, conversions and export behavior still need live testing. [K1–K4]
Exact syntax, argument order and types
=DAYSINMONTH(year;month)
| Position | Parameter | Official XML type | Required? | Meaning |
|---|---|---|---|---|
| 1 | year |
Integer | Yes | Calendar year whose February/leap status matters. |
| 2 | month |
Integer | Yes | Month number, ordinarily 1 through 12. |
Both arguments are required, and no optional argument/default is specified. The pinned registry explicitly uses setParamCount(2). The source registers a long internal compatibility alternate identifier, COM.SUN.STAR.SHEET.ADDIN.DATEFUNCTIONS.GETDAYSINMONTH, which is an alias rather than a separate function. The implementation converts both arguments to integers, constructs QDate(year,month,1), and returns date.daysInMonth() as an integer. [K1–K3]
Leap year handling: The Qt QDate Gregorian methods return 29 for February of a valid leap year. They treat 1900 as an ordinary year but 2000 as a leap year. The function does not merely inspect the month number; the year argument is essential. [Q1, K3]
Formula separators and locale: KDE’s English function handbook spells arguments with semicolons (;). Keep this syntax when following these Calligra examples; another installation or imported workbook may use a different delimiter. These date-counting functions return whole-number counts, which do not require locale-dependent date rendering, but cell types, date displays and parsing of text from external workbooks may still vary. Use numeric inputs rather than ambiguous quoted dates to reproduce the examples. [K1–K3]
Reproduce the complete seven-row example worksheet
Open a blank sheet. Enter A1 = Year, B1 = Month, and C1 = Days in month. Type A2:B8 as shown (numeric cells, not text dates). In C2 type =DAYSINMONTH(A2;B2), then fill that formula through C8. The listed counts were computed independently using the Gregorian calendar; they are expected, not observed Calligra outputs. [K1, K3, C1]
| Row | A year | B month | Formula in C | Expected C |
|---|---|---|---|---|
| 2 | 2024 | 2 | =DAYSINMONTH(A2;B2) |
29 |
| 3 | 2025 | 2 | =DAYSINMONTH(A3;B3) |
28 |
| 4 | 2000 | 2 | =DAYSINMONTH(A4;B4) |
29 |
| 5 | 1900 | 2 | =DAYSINMONTH(A5;B5) |
28 |
| 6 | 2024 | 4 | =DAYSINMONTH(A6;B6) |
30 |
| 7 | 2024 | 12 | =DAYSINMONTH(A7;B7) |
31 |
| 8 | 2025 | 11 | =DAYSINMONTH(A8;B8) |
30 |
The KDE handbook’s own DAYSINMONTH(2000;2) example gives 29. Compare 2024 and 2025 February to see the one-day difference, and compare 1900 with 2000 to see the Gregorian century rule. [K1, C1]
Advanced use: create a month-end schedule without date parsing
1. Validate an imported day-of-month number. Imagine year in A2, month in B2, and a prospective day (such as 30) in D2. To check that the day is in range for the chosen month, use:
=AND(D2>=1;D2<=DAYSINMONTH(A2;B2))
For year 2024, month 2 and day 30, the independently reasoned expected result is FALSE; day 29 returns TRUE. Calligra’s AND is separately registered in its logic module. This is a combined-formula proposal, not a native Calligra test of the combined expression. If you must guard invalid month/year inputs, validate those first instead of accepting DAYSINMONTH’s invalid-date path as an error signal. [K1–K3, C1]
2. A reusable calendar planning table. Put years down column A and month numbers in column B; copy the same formula down C to build a variable-month-length dataset. If you schedule 25 working days or estimate daily rates, month lengths cannot safely be hardcoded as 30. This is a practical spreadsheet use, not a software-specific calculation claim. [K1, C1]
3. Date-cell-driven version. Suppose E2 contains an actual date made with =DATE(2024;2;12). To get its month length, use:
=DAYSINMONTH(YEAR(E2);MONTH(E2))
Expected result: 29, since February 2024 has 29 days. Use a true date value, not locale-ambiguous text like 2/3/24. The exact conversion of imported dates has not been tested natively. [K1–K3, C1]
Input boundaries and unexpected results
Month outside 1–12: The pinned implementation directly creates QDate(year,month,1) without a separate valid-date guard, then invokes Qt’s daysInMonth(); Qt documents 0 when a date is invalid. This is a source-inferred expected 0, not a confirmed Calligra error screen or a safe data-validation strategy. Users should check 1<=month<=12 and realistic year ranges independently. [K3, Q1]
Fractional values, strings and negative years: The C++ function calls Calligra’s asInteger() conversion for each argument. That reveals the requested internal type but does not, by itself, establish rounding, textual coercion or actual installed-version error messages. Avoid quoting or mixing types in the main worksheet; mark unusual conversions for native testing. [K2, K3]
Formatting: C is an integer count, not a date serial or formatted month. If you see a date-like display, change column C’s number format without changing the input formula. [K1, K3]
Cross-product compatibility: Excel alternative
Calligra 26.08.2 directly registers DAYSINMONTH. Microsoft’s Excel date/time reference lists DATE, DAY, and EOMONTH, but not DAYSINMONTH as a built-in index entry; Excel users can calculate a comparable Gregorian month length with its documented components. With A2 year and B2 month, Excel’s usual comma delimiter: [M1]
=DAY(EOMONTH(DATE(A2,B2,1),0))
The inner DATE constructs the first day of that month, EOMONTH goes to its last day, then DAY extracts 28, 29, 30 or 31. For A2=2024 and B2=2, expected 29. Excel caveat: Excel’s 1900 date system incorrectly treats 1900 as a leap year. This alternative must not be used to validate the Calligra Gregorian result for 1900; use a modern supported year such as 2024. See Microsoft’s explanation, checked October 13, 2026. The equivalent Calligra separator spelling, if supported for your installed version, is =DAY(EOMONTH(DATE(A2;B2;1);0)), but its complete cross-function combination remains untested. Do not assume DAYSINMONTH imports unchanged into Excel, Google Sheets or another program. [K1, M1, C1]
Errors, edge cases and troubleshooting
Why did February show 28? Verify the actual year; 2024 and 2000 are leap years, 2025 and 1900 are not. A spreadsheet with a hardcoded “all divisible by 4” rule fails in years such as 1900 or 2100. [Q1, C1]
Why did an invalid month show 0 instead of an error? For an invalid Qt QDate, daysInMonth() returns 0. The examined Calligra implementation returns that result directly without checking isValid(). The precise native result should still be confirmed before relying on it in an automated workflow. [K3, Q1]
Why is it a number rather than a date? The official XML labels the return type integer. The output should be handled as a count; format it as a number rather than a date display. [K1, K3]
What we verified, and what remains untested: The name/argument layout is official-documentation checked. The function’s C++ registration and calculation branch are source-code checked against one pinned Calligra revision. The examples are independently calculated expected results, not screenshots, automated tests or results copied from an executing Calligra instance. Evaluation of nonsensical text inputs, spreadsheet import coercions, large or negative years, overflows, plugin availability in a particular package, and exact error-display labels are not native-validated. Do not use this guide as a guarantee of behavior across every installed version. [K2, K3, Q1]
Related functions and verified reference links
Use DATE to construct an actual date, DAY to extract a calendar day, MONTH to extract the month, YEAR for its year, and EOMONTH for a month-end date. These related functions perform distinct date operations. [K1]
- KDE Calligra Sheets official function reference — includes the DAYSINMONTH entry as well as its related date/time functions.
- KDE’s Calligra release listing — lists release 26.08.2 on 2026-10-08.
- Qt 6
QDatereference — documents the underlying Gregorian date methods cited below. - Microsoft’s Excel date/time function reference — a separate product, relevant only to the explicitly labelled compatibility formulas.
The four external destinations above were checked for a current response when this manuscript was drafted on 2026-10-12. [K1, K4, Q1, M1]
Official claim and method ledger
| Claim ID | What it supports | Official evidence and verification class |
|---|---|---|
| K1 | Exact named syntax, parameter types and vendor examples | KDE function handbook; documentation check 2026-10-12 |
| K2 | Release-specific function metadata; aliases or defaults | Calligra datetime.cpp pinned to 72123cc643f6625351139e7df294544255a1056f; version-pinned source check 2026-10-12 |
| K3 | Which calendar operation actually computes the result | Calligra datetime.cpp pinned to 72123cc643f6625351139e7df294544255a1056f and matching datetime.xml; version-pinned source check 2026-10-12 |
| Q1 | Gregorian day/month/year behavior and invalid-date limitations | Qt 6 QDate class documentation; documentation check 2026-10-12 |
| K4 | Release number and release date | KDE Calligra releases; release-metadata check 2026-10-12 |
| M1 | Excel alternative only, not Calligra runtime proof | Microsoft Excel date/time index and EOMONTH reference; independent vendor documentation check 2026-10-12 |
| C1 | Expected numerical outputs and leap-year cases | Independently calculated in Python’s standard-library Gregorian datetime / calendar modules, with reproducible inputs shown above; independent calculation, not native execution |