﻿---
title: ES|QL ROUND_TO function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3016/reference/query-languages/esql/functions-operators/math-functions/round_to
products:
  - Elasticsearch
---

# ES|QL ROUND_TO function
<applies-to>
  - Elastic Stack: Preview since 9.1
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/3016/reference/query-languages/esql/images/functions/round_to.svg)


## Parameters

<definitions>
  <definition term="field">
    The numeric value to round. If `null`, the function returns `null`.
  </definition>
  <definition term="points">
    Remaining rounding points. Must be constants.
  </definition>
</definitions>


## Description

Rounds down to one of a list of fixed points.

## Supported types


| field      | points     | result     |
|------------|------------|------------|
| date       | date       | date       |
| date_nanos | date_nanos | date_nanos |
| double     | double     | double     |
| double     | integer    | double     |
| double     | long       | double     |
| integer    | double     | double     |
| integer    | integer    | integer    |
| integer    | long       | long       |
| long       | double     | double     |
| long       | integer    | long       |
| long       | long       | long       |


## Example

```esql
FROM employees
| STATS COUNT(*) BY birth_window=ROUND_TO(
    birth_date,
    "1900-01-01T00:00:00Z"::DATETIME,
    "1950-01-01T00:00:00Z"::DATETIME,
    "1955-01-01T00:00:00Z"::DATETIME,
    "1960-01-01T00:00:00Z"::DATETIME,
    "1965-01-01T00:00:00Z"::DATETIME,
    "1970-01-01T00:00:00Z"::DATETIME,
    "1975-01-01T00:00:00Z"::DATETIME
)
| SORT birth_window ASC
```


| COUNT(*):long | birth_window:datetime |
|---------------|-----------------------|
| 27            | 1950-01-01T00:00:00Z  |
| 29            | 1955-01-01T00:00:00Z  |
| 33            | 1960-01-01T00:00:00Z  |
| 1             | 1965-01-01T00:00:00Z  |
| 10            | null                  |