4 Replies Latest reply on May 4, 2018 4:02 AM by vkaufmann

    Time String to consistently pull interpolated values from last day of each month?

    MattSidor

      I need to pull interpolated values at 1-month intervals from the last day of each month...specifically the last second of the last day of each month (e.g. 11:59:59 PM on January 31).

       

      I have found a query that works if the start month is January (a month with 31 days), but doesn't work if the start month is February (29 days) or April (30 days). It seems to only work with start months that have 31 days.

       

      The startTime and endTime strings are the first day of the month, plus 1 month, minus 1 second. Before percent-encoding, this string looks like (for January 2015): "2015-01-01 +1mo-1s"

       

      Example 1mo-interval query that starts in January 2015 and ends in December 2017:

       

      https://my-pi-server.com/piwebapi/streams/[some-web-id]/interpolated?startTime=2015-01-01%20%2B1mo-1s&endTime=2017-12-01%20%2B1mo-1s&interval=1mo

       

      (%20 = space, %2B = plus sign)


      Like I said, this works correctly for startTime in January, but if the startTime is February or April, many of the timestamps are off by 1-2 days.

       

      Is there a different Time String I should use instead to consistently pull the interpolated values on the last second of the last day of each month? Or perhaps a different kind of query altogether?

      (Time String reference docs: https://techsupport.osisoft.com/Documentation/PI-Web-API/help/topics/time.html)