1
0

date_trunc.asciidoc 325 B

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