Relative periods


Request a relative period

Relative periods allow you to use periods that are automatically updated based on the last minute of available data. It is no longer necessary to change the date, week, etc. in “period”: you simply need to specify which month, week, etc. you want to refer to for this last minute of available data.

The naming remains the same for granularity: but here we introduce the notion of translating the period.

To specify that it’s a relative period, we must always start with R:{}

For example, considering that the last available minute is 21 February 2017, at 23:54:


Notation Description
p1:{R:{H:0}} Current hour (23:00 to 23:54)
p1:{R:{H:-1}} Previous hour (22:00 to 22:59)
p1:{R:{D:-1}} Previous day (20 February 2017)
p1:{R:{W:-1}} Previous week (week 7)
p1:{R:{H:{start:-3,end:0}}} The 4 previous hours (20:00 to 23:54)
p1:{R:{MN:{start:-9,end:0}}} The last 10 minutes (23:45 to 23:54)
p1:{R:{M:{start:-12,end:-1}}} The last 12 months (February 2016 to January 2017)

When using these relative periods, you must verify that the request does not overlap between the current day and the previous days. For example: considering that the last available minute is 21 February 2016 at 14:34, R:{D:{start:-3,end:0}}} : this requests from the 18th to the 21st of February (impossible) R:{H:{start:-16,end:0}}} : the last 17 hours, which fall beyond the day period (21 February) Etc.


Request several relative periods

Relative periods function in the same way as when a request is made for several periods. It is possible to create different periods that are relative to each other.


&period={p1:{R:{W :0}},p2:{p1 :-1}}

Here, 2 periods are declared. The first one refers to the current week, and the second one refers to the week preceding the first period.


Here we compare the current hour, against the same hour on the day before. This also works with “MN” instead of “H”.

Was this post helpful?
Last update: 22/11/2017