I need to change the timestamp for a specific event e.g. "Timestamp = Timestamp - 5 minutes" before sending event to PI
I have tried to play around with this in my environment and it appears that when a timestamp is in "SECONDS_GMT" format, it is not possible to perform calculation on it. Timestamp calculation can only be done when it is in the format of datetime, that is, dd/mm.yy hh:mm:ss.
I would suggest you to perform the calculation on your raw data sheet first ( for example, 1433418277-300 = 1433417977). Then the final result (1433417977) will be used as input for the timestamp.
make delta a TIME type.
delta = "00:05:00"
timestamp = timestamp - delta
Check out the "Date Math" example in the latest UFL user guide for more detailed info.
When I try this I get an error:
12-Jun-2015 21:24:00 [PIIF] [Line 64] [-] Conversion error.
My configuration looks like this:
IF InStr(Tag,"Volume - actual innoculation") > 0 AND Value > 0 THEN
Timestamp = Timestamp - TimeOffset
StoreInPI(,Reactor & "_Phase",Timestamp,"Inoculation", , )
Source data looks like this:
BatchID,1,1433418277,Volume - actual innoculation,236.76
That's because of the inconsistency of the timestamp format involved in the subtraction.
If your "Timestamp" variable has the format of "SECONDS_GMT", your "TimeOffset" variable should also have the same format, which is in second.
You can either change the "Timestamp" format to be dd-mmm-yyy hh:mm:ss or change the "TimeOffset" format to be s.
*Note: if your "Timestamp" variable involves milliseconds, the "TimeOffset" format is s.nnn
Thank you for your reply. Since the timestamps in the csv file are in UTC seconds I cannot change the datatype for the Timestamp parameter but I have tried to change TimeOffset as you suggested.
Changes to the configuration:
I have also tried FORMAT="ss", TimeOffset=30 and changing TimeOffset to int32 but all combinations fail.
Since you source data is already in second unit, try to change your "Timestamp" format to second (Do not use SECONDS_GMT).
If I change format to second I get an error related to time format.
Setting for Timestamp field:
[Info] [Line 1 ] BATCHID,1,1433418277,Volume - actual innoculation,236.76.
[Error] Invalid time format: 1433418277.
Note, we are running UFL 184.108.40.206 but I have tested with same result on 220.127.116.11
This is also the conclusion I came to, too bad but I will try to see what we can do with the raw data.
Thank you very much for taking your time to look into this.
A new enhancement request has been created to address this: https://techsupport.osisoft.com/Troubleshooting/Enhancements/118924
Retrieving data ...