{
  "comment" : "This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.",
  "type" : "scalar",
  "name" : "date_trunc",
  "description" : "Rounds down a date to the closest interval since epoch, which starts at `0001-01-01T00:00:00Z`.",
  "signatures" : [
    {
      "params" : [
        {
          "name" : "interval",
          "type" : "date_period",
          "optional" : false,
          "description" : "Interval; expressed using the timespan literal syntax."
        },
        {
          "name" : "date",
          "type" : "date",
          "optional" : false,
          "description" : "Date expression"
        }
      ],
      "variadic" : false,
      "returnType" : "date"
    },
    {
      "params" : [
        {
          "name" : "interval",
          "type" : "date_period",
          "optional" : false,
          "description" : "Interval; expressed using the timespan literal syntax."
        },
        {
          "name" : "date",
          "type" : "date_nanos",
          "optional" : false,
          "description" : "Date expression"
        }
      ],
      "variadic" : false,
      "returnType" : "date_nanos"
    },
    {
      "params" : [
        {
          "name" : "interval",
          "type" : "time_duration",
          "optional" : false,
          "description" : "Interval; expressed using the timespan literal syntax."
        },
        {
          "name" : "date",
          "type" : "date",
          "optional" : false,
          "description" : "Date expression"
        }
      ],
      "variadic" : false,
      "returnType" : "date"
    },
    {
      "params" : [
        {
          "name" : "interval",
          "type" : "time_duration",
          "optional" : false,
          "description" : "Interval; expressed using the timespan literal syntax."
        },
        {
          "name" : "date",
          "type" : "date_nanos",
          "optional" : false,
          "description" : "Date expression"
        }
      ],
      "variadic" : false,
      "returnType" : "date_nanos"
    }
  ],
  "examples" : [
    "FROM employees\n| KEEP first_name, last_name, hire_date\n| EVAL year_hired = DATE_TRUNC(1 year, hire_date)",
    "FROM employees\n| EVAL year = DATE_TRUNC(1 year, hire_date)\n| STATS hires = COUNT(emp_no) BY year\n| SORT year",
    "FROM sample_data\n| EVAL error = CASE(message LIKE \"*error*\", 1, 0)\n| EVAL hour = DATE_TRUNC(1 hour, @timestamp)\n| STATS error_rate = AVG(error) by hour\n| SORT hour"
  ],
  "preview" : false,
  "snapshot_only" : false
}
