Type to search.

ES|QL TRANGE 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 9.3+

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

Availability

  • Generally available since 9.3

    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.

Filters data for a given time range using the @timestamp attribute.

Embedded
Embedded
start_time_or_offset
Offset from NOW for the single parameter mode. Start time for two parameter mode. In two parameter mode, the start time value can be a date string, date, date_nanos or epoch milliseconds.
end_time

Explicit end time that can be a date string, date, date_nanos or epoch milliseconds.

Filters data for the given time range using the @timestamp attribute.

start_time_or_offset end_time result
date date boolean
date_nanos date_nanos boolean
date_period boolean
keyword keyword boolean
long long boolean
time_duration boolean
ES|QL
FROM k8s
| WHERE TRANGE(1h)
| KEEP @timestamp
ES|QL
FROM k8s
| WHERE TRANGE("2024-05-10T00:17:14.000Z", "2024-05-10T00:18:33.000Z")
| SORT @timestamp
| KEEP @timestamp
| LIMIT 10
@timestamp:datetime
2024-05-10T00:17:16.000Z
2024-05-10T00:17:20.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:55.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
ES|QL
FROM k8s
| WHERE TRANGE(to_datetime("2024-05-10T00:17:14Z"), to_datetime("2024-05-10T00:18:33Z"))
| SORT @timestamp
| KEEP @timestamp
| LIMIT 10
@timestamp:datetime
2024-05-10T00:17:16.000Z
2024-05-10T00:17:20.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:55.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
ES|QL
FROM k8s
| WHERE TRANGE(to_datetime("2024-05-10T00:17:14.000Z"), to_datetime("2024-05-10T00:18:33.000Z"))
| SORT @timestamp
| KEEP @timestamp
| LIMIT 10
@timestamp:datetime
2024-05-10T00:17:16.000Z
2024-05-10T00:17:20.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:55.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
ES|QL
FROM k8s
| WHERE TRANGE(1715300236000, 1715300282000)
| SORT @timestamp
| KEEP @timestamp
| LIMIT 10
@timestamp:datetime
2024-05-10T00:17:20.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:30.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:39.000Z
2024-05-10T00:17:55.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z
2024-05-10T00:18:02.000Z