ES|QL DATE_PARSE function
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
Generally available
Parses a string into a date using the specified format.
datePattern- The date format. Refer to the
DateTimeFormatterdocumentation for the syntax. Ifnull, the function returnsnull. dateString- Date expression as a string. If
nullor an empty string, the function returnsnull. options-
(Optional) Additional options for date parsing, specifying time zone and locale as function named parameters.
Returns a date by parsing the second argument using the format specified in the first argument.
| datePattern | dateString | options | result |
|---|---|---|---|
| keyword | keyword | named parameters | date |
| keyword | keyword | date | |
| keyword | text | named parameters | date |
| keyword | text | date | |
| text | keyword | named parameters | date |
| text | keyword | date | |
| text | text | named parameters | date |
| text | text | date | |
| keyword | named parameters | date | |
| keyword | date | ||
| text | named parameters | date | |
| text | date |
time_zone- (keyword) Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query string to UTC.
locale-
(keyword) The locale to use when parsing the date, relevant when parsing month names or week days.
ROW date_string = "2022-05-06"
| EVAL date = DATE_PARSE("yyyy-MM-dd", date_string)
| date_string:keyword | date:date |
|---|---|
| 2022-05-06 | 2022-05-06T00:00:00.000Z |