ES|QL MONTH 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 We plan to add this functionality in a future Elastic Stack update. Subject to changes. 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
Planned
Planned
Extracts the month of year from a date.
date-
Date expression. If
null, the function returnsnull.
Extracts the month of year (1-12) from a date, using the query time zone. Equivalent to DATE_EXTRACT("month_of_year", date). This function accepts a date or date_nanos value. Unix timestamps in seconds must be converted first. For example: TO_DATETIME(start * 1000). This extract is cyclic: MONTH(ts) > 3 is not rewritten to a timestamp range.
| date | result |
|---|---|
| date | long |
| date_nanos | long |
ROW dt = to_datetime("1996-03-21T00:00:00.000Z")
| EVAL month = MONTH(dt)