Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI System Management Tools

Arithmetic operations on time values

  • Last UpdatedOct 04, 2024
  • 2 minute read

You can perform certain arithmetic operations on times, such as adding two time expressions, or subtracting one absolute time expression from another. The result of the operation is one of the following:

  • Timestamp

    A date and time in the PI timestamp format. For example: 25-aug-02 12:00:00.

  • Period

    A number of seconds.

  • Number

    A numerical value.

The following table shows valid operations and results, where N represents a number, T represents an absolute or combined time expression, and P represents a period.

Operator

Expression

Result

Example

+

T + P

T

'*' + '+3h'

T + N

T

'*' + 10

P + N

P

('t'- 'y') + 10

P + P

P

('t'- 'y') + ('t'-'y')

- (infix)

T - P

T

'*' - '+3h'

T - N

T

'*' - 10

T - T

P

't' - 'y'

P - N

P

('t'- 'y') - 10

P - P

P

('t'- '*') - ('t'-'y')

*

P * N

P

('t' -'y') * 5

N * P

P

5 * ('+1d' -'+1h')

/

P / P

N

('t'- '*') / ('t'-'y')

P / N

P

('t'- '*') / 2

N / P

N

2 / ('t'- '*')

mod

T mod P

T (see note)

'*' mod ('*'-'t')

T mod N

T (see note)

'*' mod 2

P mod P

P

('*'-'y') mod ('*'-'t')

P mod N

P

('*'-'y') mod 3

- (prefix)

-P

P

-('*'-'y')

Note: The timestamp returned is the result of T mod P or T mod N added to January 1, 1970 Universal Coordinate Time (UTC). So depending on the time zone, different results are expected; in some case, even an error value is returned. In PI for OpenVMS systems, the use of T mod P or T mod N returns P.

TitleResults for “How to create a CRG?”Also Available in