mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-29 18:03:32 -04:00
* Functions starting with A * Functions starting with 'C' * More 'C' functions * Fix tests * Fix missing snippet * DATE_* functions * Apply suggestions from code review Co-authored-by: Bogdan Pintea <pintea@mailbox.org> --------- Co-authored-by: Bogdan Pintea <pintea@mailbox.org>
56 lines
1.6 KiB
Text
56 lines
1.6 KiB
Text
[discrete]
|
|
[[esql-date_extract]]
|
|
=== `DATE_EXTRACT`
|
|
|
|
*Syntax*
|
|
|
|
[source,esql]
|
|
----
|
|
DATE_EXTRACT(date_part, date)
|
|
----
|
|
|
|
*Parameters*
|
|
|
|
`date_part`::
|
|
Part of the date to extract. Can be: `aligned_day_of_week_in_month`,
|
|
`aligned_day_of_week_in_year`, `aligned_week_of_month`, `aligned_week_of_year`,
|
|
`ampm_of_day`, `clock_hour_of_ampm`, `clock_hour_of_day`, `day_of_month`,
|
|
`day_of_week`, `day_of_year`, `epoch_day`, `era`, `hour_of_ampm`, `hour_of_day`,
|
|
`instant_seconds`, `micro_of_day`, `micro_of_second`, `milli_of_day`,
|
|
`milli_of_second`, `minute_of_day`, `minute_of_hour`, `month_of_year`,
|
|
`nano_of_day`, `nano_of_second`, `offset_seconds`, `proleptic_month`,
|
|
`second_of_day`, `second_of_minute`, `year`, or `year_of_era`. Refer to
|
|
https://docs.oracle.com/javase/8/docs/api/java/time/temporal/ChronoField.html[java.time.temporal.ChronoField]
|
|
for a description of these values.
|
|
+
|
|
If `null`, the function returns `null`.
|
|
|
|
`date`::
|
|
Date expression. If `null`, the function returns `null`.
|
|
|
|
*Description*
|
|
|
|
Extracts parts of a date, like year, month, day, hour.
|
|
|
|
*Examples*
|
|
|
|
[source.merge.styled,esql]
|
|
----
|
|
include::{esql-specs}/date.csv-spec[tag=dateExtract]
|
|
----
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
|
|===
|
|
include::{esql-specs}/date.csv-spec[tag=dateExtract-result]
|
|
|===
|
|
|
|
Find all events that occurred outside of business hours (before 9 AM or after 5
|
|
PM), on any given date:
|
|
|
|
[source.merge.styled,esql]
|
|
----
|
|
include::{esql-specs}/date.csv-spec[tag=docsDateExtractBusinessHours]
|
|
----
|
|
[%header.monospaced.styled,format=dsv,separator=|]
|
|
|===
|
|
include::{esql-specs}/date.csv-spec[tag=docsDateExtractBusinessHours-result]
|
|
|===
|