# BetweenCondition

> Class BetweenCondition represents a BETWEEN condition.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [db](/docs/api/yii/db/index.md) › [conditions](/docs/api/yii/db/conditions/index.md) › BetweenCondition

| class | `yii\db\conditions\BetweenCondition` |
| --- | --- |
| Implements | [`ConditionInterface`](/docs/api/yii/db/conditions/conditioninterface/index.md) |
| Since | 2.0.14 |
| Source | [`framework/db/conditions/BetweenCondition.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/db/conditions/BetweenCondition.php#L20) |

Class BetweenCondition represents a `BETWEEN` condition.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a condition with the `BETWEEN` operator. | `BetweenCondition` |
| [`fromArrayDefinition()`](#method-fromArrayDefinition) static | Creates object by array-definition as described in [Query Builder – Operator format](/docs/guide/db-query-builder/index.md#operator-format) guide article. | `BetweenCondition` |
| [`getColumn()`](#method-getColumn) |  | `BetweenCondition` |
| [`getIntervalEnd()`](#method-getIntervalEnd) |  | `BetweenCondition` |
| [`getIntervalStart()`](#method-getIntervalStart) |  | `BetweenCondition` |
| [`getOperator()`](#method-getOperator) |  | `BetweenCondition` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(mixed $column, string $operator, mixed $intervalStart, mixed $intervalEnd)
```

Creates a condition with the `BETWEEN` operator.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$column` | `mixed` | The literal to the left of $operator |
| `$operator` | `string` | The operator to use (e.g. `BETWEEN` or `NOT BETWEEN`) |
| `$intervalStart` | `mixed` | Beginning of the interval |
| `$intervalEnd` | `mixed` | End of the interval |

### fromArrayDefinition() <span id="method-fromArrayDefinition"></span>

```php
public static function fromArrayDefinition(mixed $operator, mixed $operands): static
```

Creates object by array-definition as described in
[Query Builder – Operator format](/docs/guide/db-query-builder/index.md#operator-format) guide article.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$operator` | `mixed` | Operator in uppercase. |
| `$operands` | `mixed` | Array of corresponding operands |

**Returns**

`static`

**Throws**

- [`yii\base\InvalidArgumentException`](/docs/api/yii/base/invalidargumentexception/index.md): if wrong number of operands have been given.

### getColumn() <span id="method-getColumn"></span>

```php
public function getColumn(): mixed
```

**Returns**

`mixed`

### getIntervalEnd() <span id="method-getIntervalEnd"></span>

```php
public function getIntervalEnd(): mixed
```

**Returns**

`mixed`

### getIntervalStart() <span id="method-getIntervalStart"></span>

```php
public function getIntervalStart(): mixed
```

**Returns**

`mixed`

### getOperator() <span id="method-getOperator"></span>

```php
public function getOperator(): string
```

**Returns**

`string`