1 Reply Latest reply on Jul 31, 2015 12:16 PM by dng

    AFCalculation

    Doddabasappa

      Hi,

       

      I have used below snippet to get previous event of tag with respect to current timestamp. It's returning timestamp which is almost 5 hours older than the last archived event's timestamp.

       

       

      String expression = "PrevEvent('Sinusoid','*')";

       

      List<AFTime> times = new List<AFTime>();

       

      times.add(new AFTime("*"));

       

       

      PIServer piserver = new PIServers().DefaultPIServer;

       

      AFValues values = AFCalculation.CalculateAtTimes(piserver, expression, times);

       

      foreach (AFValue Value in values)

      {

      }

       

      Tried with CalculateATREeordedValues, CalculateATIntervals, but still not working. Did I miss anything?

       

       

      Thanks,

       

       

        • Re: AFCalculation
          dng

          How are you getting the timestamp from AFValue.Value? Check the minute and second to see if it's exactly 5 hours off. If so, it looks like you are getting UTC time instead of local time. Try getting the local time by doing the following:

           

                      foreach (AFValue val in values)
                      {
                          AFTime time = new AFTime(val.Value);
                          Console.WriteLine(time.LocalTime);
                      }
          

           

          Do you see the correct time now?