date_diff.asciidoc 969 B

12345678910111213141516171819202122232425262728293031323334353637
  1. [discrete]
  2. [[esql-date_diff]]
  3. === `DATE_DIFF`
  4. Subtract the second argument from the third argument and return their difference in multiples of the unit specified in the first argument.
  5. If the second argument (start) is greater than the third argument (end), then negative values are returned.
  6. [cols="^,^"]
  7. |===
  8. 2+h|Datetime difference units
  9. s|unit
  10. s|abbreviations
  11. | year | years, yy, yyyy
  12. | quarter | quarters, qq, q
  13. | month | months, mm, m
  14. | dayofyear | dy, y
  15. | day | days, dd, d
  16. | week | weeks, wk, ww
  17. | weekday | weekdays, dw
  18. | hour | hours, hh
  19. | minute | minutes, mi, n
  20. | second | seconds, ss, s
  21. | millisecond | milliseconds, ms
  22. | microsecond | microseconds, mcs
  23. | nanosecond | nanoseconds, ns
  24. |===
  25. [source.merge.styled,esql]
  26. ----
  27. include::{esql-specs}/docs.csv-spec[tag=dateDiff]
  28. ----
  29. [%header.monospaced.styled,format=dsv,separator=|]
  30. |===
  31. include::{esql-specs}/docs.csv-spec[tag=dateDiff-result]
  32. |===