ES|QL MONTH function

Extracts the month of year from a date.

Embedded
date

Date expression. If null, the function returns null.

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)