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

# Date range

Date ranges allow you to filter search results by time periods.

<Tabs>
  <Tab title="API">
    In the API, you can specify the temporal filter with the request object `timestamp`.

    ```bash highlight={7-10} theme={null}
      curl -X POST 'https://api.bigdata.com/v1/search' \
      -H 'Content-Type: application/json' \
      -H 'X-API-KEY: <your-api-key>' \
      --data '{
      "query": {
        "filters": {
          "timestamp": {
            "start": "2025-09-15T22:00:00.000Z",
            "end": "2025-10-15T21:59:59.999Z"
          },
          "keyword": {
            "any_of": [
              "tesla"
            ]
          },
          "entity": {
            "any_of": [
              "228D42"
            ]
          }
        },
        "max_chunks": 2
      }
    }'
    ```
  </Tab>

  <Tab title="Python SDK">
    Two types of date ranges can be used in the search:

    * Rolling date ranges (`RollingDateRange`): Predefined relative date ranges include:

      * `RollingDateRange.LAST_ONE_HOURS`
      * `RollingDateRange.LAST_THREE_HOURS`
      * `RollingDateRange.LAST_SIX_HOURS`
      * `RollingDateRange.LAST_NINE_HOURS`
      * `RollingDateRange.LAST_TWELVE_HOURS`
      * `RollingDateRange.LAST_TWENTY_FOUR_HOURS`
      * `RollingDateRange.LAST_FORTY_EIGHT_HOURS`
      * `RollingDateRange.LAST_SEVEN_DAYS`
      * `RollingDateRange.LAST_THIRTY_DAYS`
      * `RollingDateRange.LAST_NINETY_DAYS`
      * `RollingDateRange.YEAR_TO_DATE`
      * `RollingDateRange.LAST_YEAR`

      Sunsetting:

      * ~~`RollingDateRange.TODAY`~~
      * ~~`RollingDateRange.YESTERDAY`~~
      * ~~`RollingDateRange.THIS_WEEK`~~
      * ~~`RollingDateRange.LAST_WEEK`~~

      ```python highlight={12} theme={null}
      from bigdata_client import Bigdata
      from bigdata_client.daterange import RollingDateRange
      from bigdata_client.query import Entity, Keyword

      MICROSOFT = "228D42"

      query = Entity(MICROSOFT) | Keyword("tesla")

      bigdata = Bigdata()
      search = bigdata.search.new(
          query=query,
          date_range=RollingDateRange.LAST_THIRTY_DAYS
      )

      documents = search.run(2)
      print(documents)
      ```

    * `AbsoluteDateRange`: Absolute date range defined by start and end dates. Dates must follow **ISO 8601**

    Examples:

    ```python highlight={11-17,21} theme={null}
    from bigdata_client import Bigdata
    from bigdata_client.daterange import AbsoluteDateRange
    from bigdata_client.query import Entity, Keyword
    from datetime import datetime
    import pytz

    MICROSOFT = "228D42"

    query = Entity(MICROSOFT) | Keyword("tesla")
    # The following are equivalent
    date_range = AbsoluteDateRange(datetime(2024, 1, 1), datetime(2024, 1, 31))
    date_range = AbsoluteDateRange("2024-01-01", "2024-01-31")
    date_range = AbsoluteDateRange("2024-01-01T00:00:00", "2024-01-31T00:00:00")
    # Or you can set a timezone
    end_date =  pytz.timezone("Asia/Tokyo").localize(datetime(2024, 1, 31, 9))
    date_range = AbsoluteDateRange("2024-01-01T01:00:00+01:00", end_date)

    bigdata = Bigdata()
    search = bigdata.search.new(
        query=query,
        date_range=daterange
    )

    documents = search.run(2)
    print(documents)
    ```
  </Tab>
</Tabs>
