Use one equality operator for comparison with cyclic retrieval and resolution
- Last UpdatedMar 19, 2025
- 1 minute read
If the start time is excluded (by using > instead of >=), then a gap of "resolution" is left at the beginning of the result set. In this case, the first row returned will have the timestamp of the (start date + resolution). If the end date uses "<" then the last row returned will be the last row defined by (start date + N*resolution) which has a timestamp less than the end date.
The row that equates to the time that is designated using the < (or >) operator is not returned.
Query 1
This query uses a resolution of 1000, resulting in a 1 second resolution for the data.. The starting time is set to >=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwResolution = 1000
AND DateTime >= '2001-01-13 12:00:00'
AND DateTime < '2001-01-13 12:01:00'
The results are:
|
DateTime |
Value |
|
2001-01-13 12:00:00.000 |
0 |
|
2001-01-13 12:00:01.000 |
1 |
|
2001-01-13 12:00:02.000 |
2 |
|
2001-01-13 12:00:03.000 |
3 |
|
2001-01-13 12:00:04.000 |
4 |
|
... |
|
|
2001-01-13 12:00:55.000 |
55 |
|
2001-01-13 12:00:56.000 |
56 |
|
2001-01-13 12:00:57.000 |
57 |
|
2001-01-13 12:00:58.000 |
58 |
|
2001-01-13 12:00:59.000 |
59 |
(60 row(s) affected)
Query 2
This query also uses a row resolution of 1000, resulting in a 1 second resolution for the data. The starting time is set to <=.
SELECT DateTime, Value
FROM History
WHERE TagName = 'SysTimeSec'
AND wwResolution = 1000
AND DateTime > '2001-01-13 12:00:00'
AND DateTime <= '2001-01-13 12:01:00'
The results are:
|
DateTime |
Value |
|
2001-01-13 12:00:01.000 |
1 |
|
2001-01-13 12:00:02.000 |
2 |
|
2001-01-13 12:00:03.000 |
3 |
|
2001-01-13 12:00:04.000 |
4 |
|
... |
|
|
2001-01-13 12:00:56.000 |
56 |
|
2001-01-13 12:00:57.000 |
57 |
|
2001-01-13 12:00:58.000 |
58 |
|
2001-01-13 12:00:59.000 |
59 |
|
2001-01-13 12:01:00.000 |
0 |
(60 row(s) affected)