Round (Tag-based PE function)
- Last UpdatedOct 04, 2024
- 1 minute read
- PI System
- PI Server 2023
- PI Server
Round a number or time to the nearest unit.
Syntax
Round(x [, unit])
Arguments
x
Must be an integer or real number or time expression.
unit
Optional. The size of the unit to round to. If x is a number, unit must be a number. If x is a time expression or time period, unit must be a time period. If unit is omitted, Round rounds to the nearest integer (for a number) or second (for a time period).
Returns
The nearest value to x which is an integer multiple of unit. Returns the same data type as x. For more details, see the following examples.
Exceptions
If x is a string, or if unit is of the wrong data type, returns an error value.
Notes
If x is time and unit is omitted this routine has no effect: times are accurate only to 1 second.
Example
Round(12.499)
-
Round to nearest integer (12.0)
Round(12.5)
-
Half a unit rounds up (13.0)
Round(12.8, 10)
-
Round to nearest ten (10.0)
Round('14-Dec-97 11:47, '+1h')
-
Timestamp rounded to nearest hour (14-Dec-97 12:00)
Round('18:47' -'15:00','+1h')
-
Period measured in seconds rounded to nearest hour (10800)
Note: Round to the nearest day results in a timestamp of the closest day in UTC time and not local time.