Skip to main content

Timeseries Ranges

Introduction

When specifying ranges for timeseries , curveseries, reports etc. you use the _range query parameter.

This can have one of the following values:

  • from(date)
  • from(date, tz)
  • last(number)
  • between(date, date)
  • between(date, date, tz)
  • date or within(date)
  • within(date, tz)

From function

The from function produces a date range that is from the specified date to the end of the timeseries you are requesting.

Example:

ts = ${data:"DR_EV_TEST:HOURLY"} for from("2024-12-20")

Last function

The last function doesn't use a date range, instead it returns the last n observations from the timeseries

Example:

ts = ${data:"DR_TEST:DAILY"} for last(10)

Between function

The between function creates a bounded date range where the first date is start of the range and the second date is the end of the range.

Example:

ts = ${data:"DR_TEST:DAILY"} for between("2024-12","2024-12")

Within function

The within function produces a date range covering the start and end of the date period provided. Note, it can also be used as just the date period without the within() function.

Example:

ts1 = ${data:"DR_TEST:HOURLY"} for within("2024-12-01")
ts2 = ${data:"DR_TEST:DAILY"} for "2024-12"

Date Bounds

Dates in these functions use the following standard rules according to the format provided to determine the actual date used.

  • Start and from dates always use the start of the period according to the format provided
  • End dates always use the end of the period according to the format provided.

The following table explains how the dates are determined and transformed:

FormatExampleUsed Start DateUsed End Date
yyyy20242024-01-01T00:00:002024-12-31T23:59:59
yyyy-MM2024-102024-10-01T00:00:002024-10-31T23:59:59
yyyy-MM-dd2024-10-122024-10-12T00:00:002024-10-12T23:59:59
yyyy-MM-ddT002024-10-12T112024-10-12T11:00:002024-10-12T11:59:59
yyyy-MM-ddTHH:mm2024-10-12T11:362024-10-12T11:36:002024-10-12T11:36:59
yyyy-MM-ddTHH:mm:ss2024-10-12T11:36:242024-10-12T11:36:242024-10-12T11:36:24
yyyy-MM-ddTHH:mm:ss[timezone]2024-10-12T11:36:24[Europe/Amsterdam]2024-10-12T09:36:24[UTC]2024-10-12T09:36:24[UTC]
Any absolute tenor2024M102024-10-01T00:00:002024-10-31T23:59:59

Date Rules

Date rules can be used in date ranges and will be calculated based on a reference date point of now.

Example:

ts = ${data:"DR_TEST:DAILY"} for between("T-1Y","T")

Timezones

If you pass a timezone as an argument into the function, it uses that as the timezone of the passed in date(s).

Example:

ts = ${data:"DR_TEST:HOURLY"} for between("2024-01-01","2024-01-31","Europe/Amsterdam")