# Between test

Learn how to check if a value is between two other values.

This test checks whether a value is between two other values. In terms of semantics, this test is equivalent to [chaining relational operations](/reference/cql/expressions/operations/comparison/overview#operation-chaining).

You can choose whether the test is inclusive or exclusive. That is, you can decide whether or not the value can be equal to the lower or upper bound. By default, the test is inclusive.

This test inherits the [short-circuit optimization](/reference/cql/expressions/operations/logical/overview#short-circuiting) from the logical operation. This means that if the lower-bound condition fails, the evaluation of the upper-bound condition is skipped.

## Syntax

This test has the following syntax:

```cql
/*<value>*/ is between /*<lower-bound>*/ and /*<upper-bound>*/
```

To negate the test, you can write:

```cql
/*<value>*/ is not between /*<lower-bound>*/ and /*<upper-bound>*/
```

You can also specify whether the test is inclusive or exclusive:

```cql
/*<value>*/ is between /*<lower-bound>*/ and /*<upper-bound>*/ <bound-type>
```

The following bound types are supported:

| Bound type  | Description                                                                                                          |
| ----------- | -------------------------------------------------------------------------------------------------------------------- |
| `inclusive` | Includes the lower and upper bounds when checking whether the value is between them. This is the default bound type. |
| `exclusive` | Excludes the lower and upper bounds when checking whether the value is between them.                                 |

## Parameters

These are the supported parameters:

- `value`: `comparable`

  The value to compare with two other values.

- `lower-bound`: `comparable`

  The lower bound.

- `upper-bound`: `comparable`

  The upper bound.

## Examples

Here is a basic example of how to check whether a value is between two other values:

```cql
1 is between 1 and 3 // true
```

To make the test exclusive, you can write:

```cql
1 is between 1 and 3 exclusive // false
```

It also works with date and time values:

```cql
today is between yesterday and tomorrow // true
```
