elasticsearch/docs/reference/esql/functions/examples/date_diff.asciidoc

25 lines
798 B
Plaintext

// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
*Examples*
[source.merge.styled,esql]
----
include::{esql-specs}/date.csv-spec[tag=docsDateDiff]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/date.csv-spec[tag=docsDateDiff-result]
|===
When subtracting in calendar units - like year, month a.s.o. - only the fully elapsed units are counted.
To avoid this and obtain also remainders, simply switch to the next smaller unit and do the date math accordingly.
[source.merge.styled,esql]
----
include::{esql-specs}/date.csv-spec[tag=evalDateDiffYearForDocs]
----
[%header.monospaced.styled,format=dsv,separator=|]
|===
include::{esql-specs}/date.csv-spec[tag=evalDateDiffYearForDocs-result]
|===