<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/google/meridian/blob/v2.2.1/meridian/model/spec.py#L47-L121) |

A date range `[start_date, end_date]` with both bounds inclusive.

```python
meridian.model.spec.DateRange(
    start_date: `meridian.data.time_coordinates.Date` = None,
    end_date: `meridian.data.time_coordinates.Date` = None
)
```

This matches the convention used throughout Meridian's other date selection
APIs -- notably [`TimeCoordinates.get_selected_dates`](https://developers.google.com/meridian/reference/api/meridian/data/time_coordinates/TimeCoordinates.md.txt#get_selected_dates) and
`expand_selected_time_dims` -- so that the same pair of dates selects the
same time periods wherever it is used.

Either bound may be omitted to leave that side open. An omitted bound is
resolved against the input data when the range is compiled, not at
construction time, so the same `DateRange` may cover different dates for
different datasets:

- `DateRange(start, None)`: from `start` through the last date in the data.
- `DateRange(None, end)`: from the first date in the data through `end`.
- `DateRange()`: the entire date range of the data. This is the identity range; specifying it is equivalent to applying no date restriction at all.

A range whose bounds are equal is valid and selects that single date.

A bound that is present must name one of the input data's time coordinates
exactly; a bound falling between two coordinates is rejected. Because it
depends on the data, the check happens when the range is compiled against an
`InputData`, not at construction time.

<br />

<br />

<br />

| ## Note ||
|---|---|
| The `mmm.v1.common.DateInterval` proto that these specs serialize to uses the opposite, *half-open* `[start_date, end_date)` convention. The conversion between the two is performed in the serialization layer, which is the only place the two conventions meet. ||

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `start_date` | The start date (inclusive). Can be a `datetime.date`, `datetime.datetime`, `np.datetime64`, or an ISO-formatted string ('YYYY-MM-DD'). If None, implies all dates up to `end_date`. |
| `end_date` | The end date (inclusive). Can be a `datetime.date`, `datetime.datetime`, `np.datetime64`, or an ISO-formatted string ('YYYY-MM-DD'). If None, implies all dates from `start_date` onwards. |
| `date_interval` | Returns a normalized, inclusive `(start_date, end_date)` tuple. |

<br />

## Methods

### `from_date_interval`

[View source](https://github.com/google/meridian/blob/v2.2.1/meridian/model/spec.py#L99-L116)

```python
@classmethod
from_date_interval(
    date_interval: `meridian.data.time_coordinates.DateInterval`
) -> 'DateRange'
```

Creates a `DateRange` from a [`time_coordinates.DateInterval`](https://developers.google.com/meridian/reference/api/meridian/data/time_coordinates/DateInterval.md.txt) tuple.

The tuple is interpreted with both bounds *inclusive* , the convention
[`TimeCoordinates.get_selected_dates`](https://developers.google.com/meridian/reference/api/meridian/data/time_coordinates/TimeCoordinates.md.txt#get_selected_dates) uses. It is therefore not
interchangeable with the half-open `mmm.v1.common.DateInterval` proto of
the same name.

<br />

<br />

<br />

| Args ||
|---|---|
| `date_interval` | An inclusive `(start_date, end_date)` tuple. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The equivalent `DateRange`. ||

<br />

### `__eq__`

```python
__eq__(
    other
)
```

Return self==value.

<br />

<br />

<br />

| ## Class Variables ||
|---|---|
| end_date | `None` |
| start_date | `None` |

<br />