Closed selimnairb closed 5 years ago
Sorry @hylkevds here is another issue that has been kicking around in my head for the last few weeks ...
You can already do that, using normal add and sub, with durations. I had a slide about that in my presentation on the summit. The duration format is part of the ISO time standard (https://en.wikipedia.org/wiki/ISO_8601#Durations) and the OData way to put them in URLs is using duration'P<date>T<time>'
Some examples from https://github.com/FraunhoferIOSB/FROST-Server/wiki/Example-queries :
The observations of a Datastream, for the last day:
Datastreams(1)/Observations?$filter=phenomenonTime gt now() sub duration'P1D'
The observations of a Datastream, for the last days, where the number of days is configured in properties/days of the Datastream:
Datastreams(1)/Observations?$filter=phenomenonTime gt now() sub duration'P1D' mul Datastream/properties/days
@hylkevds As I suspected. Thanks for the information. I will close this.
I may be misinterpreting some of OData's datetime capabilities, but if not, here is a use case I would like to see supported for $filter in STA 1.1.
As a dashboard or analytics developer, I would like to be able to query for Observations based on date/time arithmetic from
now()
. For example, I would like to be able to query Observations within that last 5 minutes, or last 5 seconds, etc. without having to formulate and include the relevant datetime string my query. So, if I want to fetch Observations that are less than 5 seconds old, instead of having to write this query:(assuming the current time is 2018-11-16T18:00:00Z)
I want to be able to say something like:
Where
dtincdec()
is short for increment or decrement a datetime.Without this capability, there are some time queries that are difficult/impossible to do. In the example above, if the request latency is greater than N seconds, I can't reliably ask the server for Observations that are at most N seconds old (at the time of query).