DURATION examples
- Last UpdatedMar 04, 2025
- 2 minute read
Example 1
The following expression returns the amount of time in seconds over the specified interval that the number of seconds in the time is 20 or greater.
DURATION(SysTimeSec >= 20)
Example 2
The following expression returns the amount of time per one hour interval that a tank's level is at or above 500 kL.
DURATION(Tank400.Level > 500, hour)
Represented as a query:
SELECT DateTime, Value, OPCQuality
FROM History
WHERE wwExpression = 'DURATION(Tank400.Level >= 500, hour)'
AND DateTime > '2022-04-03 00:00:00'
AND DateTime < '2022-04-04 00:00:00'
Results:
|
DateTime |
Value |
OPCQuality |
|
2022-04-03 01:00:00.0000000 |
3600 |
192 |
|
2022-04-03 02:00:00.0000000 |
3578 |
192 |
|
2022-04-03 03:00:00.0000000 |
3592 |
192 |
|
... |
... |
... |
|
2022-04-03 23:00:00.0000000 |
94 |
192 |
Represented as a line chart over a 1 day interval:

Example 3
The following expression returns the amount of time in seconds that the second value of the time is 20 or greater, over 5 minute intervals.
DURATION(SysTimeSec >= 20, 5 minute)
Represented as a query:
SELECT DateTime, Value, OPCQuality
FROM History
WHERE wwExpression = 'DURATION(SysTimeSec >= 20, 5 minute)'
Results:
|
DateTime |
Value |
OPCQuality |
|
2022-04-01 08:45:00.0000000 |
200 |
192 |
|
2022-04-01 08:50:00.0000000 |
200 |
192 |
|
2022-04-01 08:55:00.0000000 |
200 |
192 |
|
2022-04-01 09:00:00.0000000 |
200 |
192 |
|
... |
... |
... |
Example 4
The following expression returns the amount of time in seconds that the second value of the time is 20 or greater over 30 second intervals, and the results are converted to minutes.
UOM(DURATION(SysTimeSec >= 20, 0.5 minute), Minute)