Type to search.

ES|QL DATE_PARSE function

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    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.

Parses a string into a date using the specified format.

Embedded
Embedded
datePattern
The date format. Refer to the DateTimeFormatter documentation for the syntax. If null, the function returns null.
dateString
Date expression as a string. If null or an empty string, the function returns null.
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.

ES|QL
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