elasticsearch/docs/reference/esql/functions/date_trunc.asciidoc

14 lines
325 B
Plaintext

[discrete]
[[esql-date_trunc]]
=== `DATE_TRUNC`
Rounds down a date to the closest interval. Intervals can be expressed using the
<<esql-timespan-literals,timespan literal syntax>>.
[source,esql]
----
FROM employees
| EVAL year_hired = DATE_TRUNC(1 year, hire_date)
| STATS count(emp_no) BY year_hired
| SORT year_hired
----