Type to search.

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

Returns a string representation of a date, in the provided format.

Embedded
Embedded
dateFormat
Date format (optional). If no format is specified, the yyyy-MM-dd'T'HH:mm:ss.SSSZ format is used. If null, the function returns null.
date

Date expression. If null, the function returns null.

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