How do we determine the earliest date of recorded value in PI archive using C#?
Any help appreciated!
I solved it using your earlier post as follwos:
time = new AFTime(1.0);
AFValue firstKnownEvent = point.RecordedValue(time, AFRetrievalMode.After);
Thanks again for your help. It seems to me that the other method using AFTime.MinValue seemed to look backwards from the present instead of forward from the min time.
I remember answering this question 2 years ago. Let me reword your question. How can I determine the earliest recorded date for an historical tag in the PI Data Archive? (I am conveniently skipping future tags in this discussion.) You mention C#. The key here isn't the programming language but the PI Developer Technology: AF SDK. You would use the PIPoint.RecordedValue method. The trick is to ask for the earliest known date of January 1, 1970, but with an AFRetrievalMode of After.
Assuming you have a variable named tag which is a valid PIPoint object:
AFTime firstKnownEvent = tag.RecordedValue(AFTime.MinValue, AFRetrievalMode.After);
You can also perform something similar with Analytics with an expression such as:
Sorry about taking coward's way out with future tags.
Simple and clever!
Thanks very much. However, I get an error with the code you posted. The tag is a valid PIPoint object (used in other parts of my code successfully). The code works when I modify it as follows:
AFValue firstKnownEvent = tag.RecordedValue(AFTime.MinValue, AFRetrievalMode.After);
However, this gives me the most recent tag value for some reason.... what am I doing wrong??!!
All help appreciated as always!
Superficially it sounds like the tag is not being historized. Could you use SMT to find the first recorded event for the tag in question. Use the 3 parameters highlighted in red below.
PS - Yes, my SINUSOID is only a few weeks old. I had corrupted my system a few weeks ago and rebuilt my archive.
Yes, it is being historized. There are millions of data points in the archive for the tag. Below is a snippet of the approximate time of earliest recorded value that I am trying to pick up taken from ProcessBook.
Retrieving data ...