date_trunc.asciidoc 314 B

123456789101112
  1. [[esql-date_trunc]]
  2. === `DATE_TRUNC`
  3. Rounds down a date to the closest interval. Intervals can be expressed using the
  4. <<esql-timespan-literals,timespan literal syntax>>.
  5. [source,esql]
  6. ----
  7. FROM employees
  8. | EVAL year_hired = DATE_TRUNC(hire_date, 1 year)
  9. | STATS count(emp_no) BY year_hired
  10. | SORT year_hired
  11. ----