https://bugs.documentfoundation.org/show_bug.cgi?id=171969

--- Comment #7 from [email protected] ---
I understand the argument about interoperability and backward compatibility,
but I think it is worth pointing out that DATEDIF is still a very useful
function from a user's point of view.

Replacing some DATEDIF calculations with other functions can result in formulas
that are considerably more complex and much harder to read.

For example, calculating the total number of days is trivial:

```text
=B2-A2
```

But calculating complete years without DATEDIF already requires a much more
complicated expression, such as:

```text
=YEAR(B2)-YEAR(A2)-IF(EDATE(A2;12*(YEAR(B2)-YEAR(A2)))>B2;1;0)
```

Calculating complete months is even less readable:

```text
=12*(YEAR(B2)-YEAR(A2))+MONTH(B2)-MONTH(A2)
 -IF(EDATE(A2;12*(YEAR(B2)-YEAR(A2))+MONTH(B2)-MONTH(A2))>B2;1;0)
```

With DATEDIF, the same calculations are simply:

```text
=DATEDIF(A2;B2;"y")
=DATEDIF(A2;B2;"m")
```

The same applies to the remaining components `"ym"`, `"md"` and `"yd"`.

This is why I do not think DATEDIF should be regarded only as a legacy function
that users should avoid. Its interface is concise, expressive and very
convenient, and replacing it with combinations of YEAR(), MONTH(), EDATE(),
IF(), etc. makes spreadsheets significantly harder to understand and maintain.

In particular, `"md"` expresses a very useful operation: the number of
remaining days after subtracting complete months and years. The problem is not
the usefulness of the operation, but the historical implementation of that
particular interval.

For that reason, I still think there is value in distinguishing between
preserving Excel-compatible behaviour where interoperability requires it and
providing a correct OpenFormula/ODF behaviour for native Calc documents.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to