ES|QL DATE_FORMAT function
dateFormat- Date format (optional). If no format is specified, the
yyyy-MM-dd'T'HH:mm:ss.SSSZformat is used. Ifnull, the function returnsnull. date-
Date expression. If
null, the function returnsnull.
Returns a string representation of a date, in the provided format.
| dateFormat | date | result |
|---|---|---|
| keyword | date | keyword |
| keyword | date_nanos | keyword |
| text | date | keyword |
| text | date_nanos | keyword |
| date | keyword | |
| date_nanos | keyword |
FROM employees
| KEEP first_name, last_name, hire_date
| EVAL hired = DATE_FORMAT("yyyy-MM-dd", hire_date)
| first_name:keyword | last_name:keyword | hire_date:date | hired:keyword |
|---|---|---|---|
| Alejandro | McAlpine | 1991-06-26T00:00:00.000Z | 1991-06-26 |
| Amabile | Gomatam | 1992-11-18T00:00:00.000Z | 1992-11-18 |
| Anneke | Preusig | 1989-06-02T00:00:00.000Z | 1989-06-02 |