DATEDIF Function in WPS Spreadsheet: Syntax, Examples and Compatibility
Use DATEDIF in WPS Spreadsheet to measure completed years or days between two dates without counting partial anniversaries as full years. Two original examples, expected results, cautions and official software documentation.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: DATEDIF returns a requested year, month or day interval between two dates. Supply a quoted unit code and keep calendar intervals distinct from a fraction of a year or a simple subtraction of date components.
Availability and version history
- Introduced: documented by 2019-05-13 in the WPS lesson; original introduction is not established.
- Availability: historical Windows Personal lesson and current Windows FAQ; no minimum numeric build is specified.
- Scope: Windows documentation does not establish equivalent behavior in every other WPS client.
- Checked: October 14, 2026. Complete function-specific references and independent calendar models; no native WPS test was performed.
Syntax and arguments
=DATEDIF(start_date, end_date, unit)
All three arguments are required. The WPS source explicitly lists Y, M, D, YD, MD and YM. Its examples use uppercase quoted codes; the walkthrough warns that an unquoted unit can produce #NAME?. The controls here use start dates no later than end dates.
Use English function names and comma separators as shown, adapting separators for the workbook locale. Display date/date-time outputs with an appropriate format and counts or durations as numbers. Expected outputs are independent models; live-clock and endpoint assumptions are explicit.
Example 1: original control
=DATEDIF(DATE(2020,1,1),DATE(2025,1,1),"Y")
Stated counting-model output: 5.
Five complete anniversaries occurred between 1 January 2020 and 1 January 2025.
Example 2: original comparison
=DATEDIF(DATE(2025,1,10),DATE(2025,2,9),"D")
Stated counting-model output: 30.
Subtracting the two date serials yields 30 elapsed days.
Documented units and boundary scope
| Unit | Requested interval |
|---|---|
"Y" |
Years between dates |
"M" |
Months between dates |
"D" |
Days between dates |
"YD" |
Day interval with years ignored |
"MD" |
Day interval with years and months ignored |
"YM" |
Month interval with years ignored |
These descriptions come from the WPS function table and walkthrough. They do not supply a complete algorithm for every month-end, leap-day or reversed-date case. The worked whole-unit models below use ordinary dates and state exactly what is being counted.
Example 3: compare units on the same ordinary interval
Put =DATE(2020,5,15) in A2 and =DATE(2026,8,20) in B2. The independently calculated whole-unit model gives:
| Formula | Expected model result |
|---|---|
=DATEDIF(A2,B2,"Y") |
6 |
=DATEDIF(A2,B2,"M") |
75 |
=DATEDIF(A2,B2,"D") |
2288 |
=DATEDIF(A2,B2,"YM") |
3 |
=DATEDIF(A2,B2,"MD") |
5 |
=DATEDIF(A2,B2,"YD") |
97 |
There are six completed ordinary anniversaries, 75 completed month steps, and five further days after 15 August in this model. The YD comparison spans 15 May to 20 August within the final year. These controls do not certify all shorter-month or leap-day variants.
Advanced example: a year-label difference is not an anniversary
Compare the fixed start 15 May 2020 with ends 14 May, 15 May and 16 May 2026. Under a completed-anniversary model, the expected Y results are 5, 6 and 6.
A simple YEAR(end)-YEAR(start) returns 6 for all three and cannot express the before-anniversary boundary. Keep these as explicit native-check controls when exact anniversary policy matters; the captured WPS table names the unit but does not spell out every partial-year boundary rule.
For a deadline requiring a fixed number of days, use the day interval rather than converting a year into an arbitrary 365-day constant. Leap years make the latter a different policy.
Advanced example: separate total months from remaining months
For the A2:B2 ordinary interval above, the model’s 75 total months consist of 6×12 + 3. M and YM therefore answer different questions. Adding the five-day MD remainder can describe this particular interval in a human-readable form, but it is not a general proof that all unit outputs can be recombined without month-end ambiguity.
A same-day-of-month control from 15 Jan 2026 to 15 Mar 2026 has model expectation 2 months, while the elapsed day count is 59. In 2024 the corresponding dates span 60 days. Calendar months do not have a fixed length.
Advanced example: retain a fixed as-of date
For an anniversary report, put an explicit as-of date in H2 and a valid start date in D2:
=DATEDIF(D2,$H$2,"Y")
The fixed end reference keeps every row tied to the same reporting date. If TODAY is substituted for H2, the report can change after the calculated date advances. Record the as-of value when a historical result must remain reproducible.
This formula does not validate a missing start date or choose an organizational anniversary policy. Inspect invalid or reversed inputs separately; the exact native error codes for those cases remain held by this review.
Product-specific cautions
The earlier guide imported Microsoft’s MD warning into WPS. The WPS source independently documents MD, but the captured evidence does not establish that Excel’s particular defect or workaround applies here. The current Windows FAQ also leaves the detailed month-end algorithm unspecified. The revised guide retains a WPS-specific month-end boundary hold instead of asserting another product’s bug.
Recognized text-date parsing, time-of-day fractions, lower-case unit acceptance, every leap-day endpoint and exact malformed-unit errors remain unverified. Use DATE for controlled inputs and YEAR only when the calendar-year component itself is the question. No native WPS execution was performed.
Related guides and verification
- YEAR in WPS Spreadsheet
- DATE in WPS Spreadsheet
- NETWORKDAYS in WPS Spreadsheet
- Compare DATEDIF in Microsoft Excel
- Compare DATEDIF in Google Sheets
Corresponding functions in another product require separate evidence for clock, endpoint, date-system and error behavior.
- WPS Academy: DATEDIF, 2019-05-13 (Chinese; Windows Personal).
- WPS Academy: DATE.
- WPS Windows DATEDIF FAQ.
- Editorial testing standards.
Evidence level: Full article and complete product-specific sources reviewed. Original title, publication date and two worked formulas are preserved. Additional calendar and time calculations are independently modeled; no native clock, application or import test is claimed.