> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.cloudquant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Required Timestamps in Queries

> Every Liberator query must include a valid date or time range using back_to and as_of (or an explicit WHERE on time columns)

# Required timestamps in queries

Liberator enforces a **time-based predicate on all queries**. Every query must include a valid, non-zero date or time range. Queries without one return an error and no data.

Previously, a query with no time parameters could return an entire dataset. That behavior was removed to prevent unexpectedly large result sets and unnecessary load.

<Warning>
  Review saved notebooks, scripts, and scheduled jobs. Any query that omits `back_to` / `as_of` (or an explicit time `WHERE` in raw `sql`) will fail until updated.
</Warning>

Applies to Liberator **2.1 and later**.

## Valid timestamps

A valid time scope must:

* Cover a **specific date, date range, or datetime range** — not zero, null, or empty.
* Use **`back_to` and `as_of`** for parameter-based queries (Liberator's point-in-time window). See [Understanding as\_of and back\_to](/python-guide/as-of-and-back-to).
* Fall within the dataset's available coverage (valid dates outside coverage return an **empty** result, not a timestamp error).

### Correct examples

```python theme={null}
import liberator

# Single day
df = liberator.get_dataframe(liberator.query(
    name="my_dataset",
    symbols=["AAPL"],
    back_to="2026-01-01",
    as_of="2026-01-01",
))

# Date range
df = liberator.get_dataframe(liberator.query(
    name="my_dataset",
    symbols=["AAPL"],
    back_to="2026-01-01",
    as_of="2026-06-30",
))

# Datetime range
df = liberator.get_dataframe(liberator.query(
    name="my_dataset",
    symbols=["AAPL"],
    back_to="2026-06-01 09:30:00",
    as_of="2026-06-01 16:00:00",
))
```

### Incorrect examples

```python theme={null}
# Missing back_to and as_of — error
liberator.query(name="my_dataset", symbols=["AAPL"])

# Null dates — error
liberator.query(name="my_dataset", symbols=["AAPL"], back_to=None, as_of=None)
```

### Raw `sql` queries

Every `SELECT` must include an explicit **`WHERE`** clause with a time-range predicate on `muts` or another configured time column. See [Query parameters — Raw SQL](/python-guide/query-parameters#raw-sql-queries).

## What the error looks like

The API or client returns an error indicating a time-based predicate is required. This is expected enforcement, not a platform failure.

## Update existing queries

1. **Find affected calls** — Search for `liberator.query()` without `back_to` / `as_of`, or raw `sql` without a time `WHERE`.
2. **Choose the right window** — Daily jobs: parameterize to yesterday or today. Historical pulls: set explicit start and end dates.
3. **Add parameters** — Use the examples above.
4. **Test** — Run manually before re-enabling schedules.

## FAQ

**I used to pull a full dataset for reference. What now?**\
Set `back_to` and `as_of` to the dataset's available range (ask your administrator or check dataset details in the admin portal).

**Error but I provided dates?**\
Confirm values are not null/empty, `back_to` is not after `as_of`, and dates use `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`.

**Valid dates but empty results?**\
The timestamp is accepted; the range may fall outside dataset coverage.

**AI assistant queries?**\
Assistants must specify a time range. Timeless requests should prompt for dates; otherwise the query fails like any other.

## Related

<CardGroup cols={2}>
  <Card title="as_of and back_to" icon="clock" href="/python-guide/as-of-and-back-to">
    Point-in-time semantics for Liberator datasets
  </Card>

  <Card title="Query parameters" icon="code" href="/python-guide/query-parameters">
    Full parameter reference including raw SQL rules
  </Card>
</CardGroup>
