How do I construct a timeSeries for the Aggregations API?
A timeSeries consists of three components:
-
period refers to the type of unit of time in which we will group our data selections. You can use dayRange to query in a number of days, or monthRange to query in a number of months. While our backend does support a significantly larger number of values than these two, only dayRange and monthRange are available to our customers for performance purposes.
-
first refers to the start of your time selection, in Unix Time. You can also use now() to start at the moment of running.
- count refers to the number and direction of period's we are selecting, starting from first. Note that you can also use last with a unix time stamp instead to target a specific range of time, modified by the period.
As an example, I can explain the timeSeries offered in my previous example:
"timeSeries": {
"period": "dayRange",
"first": "1541715642972",
"count": -7
}
Breaking this down one step at a time --
-
period is dayRange, so we'll be selecting entire days' worth of time. Note that the smallest amount of time we can select here is one full calendar day, starting from midnight of that day, up to midnight of the following day.
-
first is starting at midnight on 11/08/18, as indicated by the Epoch timevalue conversion.
- count will, starting from now(), count 7 days back in time (as indicated by the negative count).
We would expect this timeSeries to target every event that took place between 11/2 and 11/8, including the entirety of the 2nd and the 8th.
-1
Comments
Hi there! Is it possible to expand this to a period of 30 days to look back from the current date? Can you provide an example of how that would look in the data body of the request?
Hi Howard Lio
I used following timeSeries properties and schedule this to run at 12:00AM UTC. When this was last run at 7/31/2024 12AM, it was supposed to give yesterday's data i.e. 7/30 but see below what data is it giving :
select min(dateTime) as minDate,max(dateTime) as maxDate from [UTD].[tbl_trackevents] where CAST(dltProcessedDate as Date) = CAST(getdate() as date)
Output:
minDate - 2024-07-29 05:04:03.957
maxDate - 2024-07-30 03:54:47.077
Wondering why it is giving me 07/29/2024 data ?
Please sign in to leave a comment.