Home · Command reference

RainbowStats™ · Command reference

SERIES_BETWEEN — Select a Date Interval

Keep observations within an explicit starting and ending date.

SERIES_BETWEEN selects an interval from a single series or from each member of a data-series list. Use it for historical samples, event windows and reproducible comparisons with a fixed endpoint.

Quick start: a fixed historical sample

LINE_CHART(SERIES_BETWEEN(UNRATE,20200101,20241231))

Run this example in RainbowStats

This charts unemployment observations dated within January 1, 2020 through December 31, 2024. It uses stored observation dates; a December monthly observation may be labeled December 1 rather than December 31.

Syntax, alias and input types

SERIES_BETWEEN(series,start,end)
SERIES_BETWEEN(seriesList,start,end)
BETWEEN(series,start,end)
Argument or formMeaning
seriesAn individual series. Returns a series.
seriesListA data-series list. Selects the interval from each member and returns a list.
start, endNumeric dates as YYYYMMDD, such as 20200101 and 20241231. Supply valid dates in chronological order.
BETWEENRegistered alias for SERIES_BETWEEN.
LIST_BETWEEN(list,start,end)Separate list-specific command in the supplied dispatcher. Its input must be a data-series list; use SERIES_BETWEEN for either input type.

Supply three arguments. Date variables are supported when their values are numeric. Quoted date strings and an implicit omitted end date are not supported by this dispatcher form.

Inclusive boundaries and stored dates

Live tests retained observations on both boundaries. For monthly unemployment:

CallReturned observation dates
SERIES_BETWEEN(UNRATE,20240201,20240401)February 1, March 1 and April 1, 2024.
SERIES_BETWEEN(UNRATE,20240215,20240415)March 1 and April 1, 2024.
SERIES_BETWEEN(UNRATE,20240301,20240301)The March 1, 2024 observation.

The supplied method passes each stored observation date through its date-range predicate, copying selected dates and values while retaining frequency, units and source. It does not synthesize observations at either boundary.

Choose boundaries using the source’s date labels. A monthly value labeled February 1 falls outside a window beginning February 15, even though it describes February. An end date after the latest observation does not create additional values.

Examples: series, lists and event samples

Use numeric date variables

start = 20240201
end = 20240401
sample = SERIES_BETWEEN(UNRATE,start,end)
LINE_CHART(sample)

Clip a list before regression

levels = LIST(UNRATE,U6RATE,TCU)
sample = SERIES_BETWEEN(levels,20010101,20191231)
r = REGRESSION(sample)
EXTRACT(r,"slideshow")

All members are restricted to the requested historical interval, but their actual source coverage can still differ.

Chart a daily historical window

sample = SERIES_BETWEEN(DGS10,20200301,20200630)
LINE_CHART(SET_NAME(sample,"10-year Treasury yield, March–June 2020"))

Align after selecting a window

sample = SERIES_BETWEEN(LIST(UNRATE,U6RATE),20200101,20241231)
aligned = SAME_DATE_RANGE(sample)
LINE_CHART(aligned)

Transform before clipping when history is needed

history = SERIES_BETWEEN(PAYEMS,20190101,20241231)
changes = DIFF(history)
display = SERIES_BETWEEN(changes,20200101,20241231)
LINE_CHART(display)

The longer input history supplies the predecessor needed to calculate the first displayed change. Differencing a sample that begins in January 2020 cannot use the December 2019 level if it has already been removed.

CommandPurposeReturn type
SERIES_SINCE(data,start)Retain observations from a selected starting cutoff through the available end of the input.Series for a series input; list for a list input.
SERIES_BETWEEN(data,start,end)Retain observations within an explicit date interval.Series for a series input; list for a list input.
SAME_DATE_RANGE(data,...)Align overlapping series to a reference observation-date grid, interpolating where needed.Always a data-series list, including for a single series input.

Working with the data