Difference between two dates in the chosen unit.
| Field | Value |
|---|---|
| Category | Date and time |
| Type | Scalar (operates value by value) |
| Arity | 3 arguments (fixed) |
| Compiles to SQL (calculated column) | Yes |
| Version | Formula engine v3. |
Aliases#
Canonical name: DATADIF. Accepted aliases (case-insensitive): datediff.
Syntax#
code
DATADIF(expr; arg2; arg3)All arguments are expressions.
Returns#
Number.
Null handling#
Invalid or missing dates become a friendly error or blank, depending on the function.
Evaluation context#
Scalar — evaluated on the result of the arguments (in calculated columns, it runs row by row).
Differences from DAX#
- DAX equivalent: DATEDIFF
- Compatibility: DIFFERS from DAX — different semantics, watch out
- Note: Only the units DIA, MES, and ANO — DAX DATEDIFF has SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, and YEAR.
Examples#
code
DATADIF(pedido_em; entregue_em; "DIA")Example with values#
Input: from 2025-01-01 to 2025-03-31, in days.
code
DATADIF("2025-01-01"; "2025-03-31"; "DIA") → 89Expected result: 89
Business example#
Delivery lead time in days, from order to delivery.
Common errors#
DATADIF: unidade deve ser "DIA", "MES" ou "ANO" · DATADIF: "…" não é uma data.