elasticsearch/docs/reference/esql/functions/date_diff.asciidoc
Luigi Dell'Aquila 770fc19b14
ESQL: add date_diff function (#104118)
Same as https://github.com/elastic/elasticsearch/pull/103208

Fixes #101942

We had to revert it after a Checkstyle failure (strange it didn't pop up
in the CI before merging)
2024-01-09 07:03:58 -05:00

37 lines
969 B
Text

[discrete]
[[esql-date_diff]]
=== `DATE_DIFF`
Subtract the second argument from the third argument and return their difference in multiples of the unit specified in the first argument.
If the second argument (start) is greater than the third argument (end), then negative values are returned.
[cols="^,^"]
|===
2+h|Datetime difference units
s|unit
s|abbreviations
| year | years, yy, yyyy
| quarter | quarters, qq, q
| month | months, mm, m
| dayofyear | dy, y
| day | days, dd, d
| week | weeks, wk, ww
| weekday | weekdays, dw
| hour | hours, hh
| minute | minutes, mi, n
| second | seconds, ss, s
| millisecond | milliseconds, ms
| microsecond | microseconds, mcs
| nanosecond | nanoseconds, ns
|===
[source.merge.styled,esql]
----
include::{esql-specs}/docs.csv-spec[tag=dateDiff]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/docs.csv-spec[tag=dateDiff-result]
|===