Handling Time Zone Differences in PI Analysis for Daily and Monthly Totals

I am new to PI Analysis, and I am facing an issue with time zone differences. My data is stored in UTC, but the AF Analysis is performed in Central Time. Because of this, my daily and monthly totals are incorrect when using

'*'

 

for daily totals or

"BOM*"

for monthly totals.

Is there a way to handle this time zone mismatch by hard coding the dates or adjusting them iteratively in PI Analysis formulas? I would appreciate any guidance or suggestions on how to approach this.

Thanks in advance!

  • Hi Nash,

    The PI System stores all data in UTC. This means that any local time adjustments, including Daylight Saving Time (DST), are handled on the client side, not within the server itself12

    When writing AF Analysis formulas, you can utilize time expressions to adjust for time zones. For example, you can specify a time offset using expressions like t-6h to convert UTC to Central Time (UTC-6) or t-5h,during Daylight Saving Time (UTC-5)1.

     

    You can hard code dates in your formulas by specifying exact times adjusted for the Central Time zone. For example:

    For daily totals:text

    TotalDaily = Sum('YourTag', "t-6h", "t")

     

    This expression sums the values from the previous day at midnight Central Time.

    For monthly totals:text

     

    TotalMonthly = Sum('YourTag', "BOM-t-6h", "EOM-t-6h")

    This sums the values from the start of the month to the end of the month, adjusted for Central Time.

    If hard coding is not feasible due to variable date ranges or other factors, consider using iterative adjustments within your analysis:

    Using: TimeZoneInfo.ConvertTime()

     

    If you're programming with the AF SDK, you can convert times dynamically:

    csharp: DateTime utcTime = ...; // Your UTC time

    DateTime centralTime = TimeZoneInfo.ConvertTime(utcTime, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));

     

    The AF SDK can automatically handle time zone differences when retrieving data from the PI Data Archive, ensuring that calculations reflect the correct local time4.

     

  • Thanks for the help! I have a few more questions.

    I tried using

    "EOM"

    to get the end of the month, but it doesn’t seem to work as expected. Is there another way to accurately determine the end of the month in PI Analysis?

    Appreciate your continued assistance!

  • Hi Nash,

     

    Unfortunately, there is no simple way to get produce what we think should be simple results. The answer by Hupert does not take into account DST.

     

    There is a round about way to get it and I refer you to this blog:

    Exact Shift Starts Asset Analytics and Daylight Saving Time -DST

     

     Also, there is a subtle difference between relative times of '-1d' and '-24h'. For '-1d', what happens is the time zone on the host executing the analysis is used for whatever it thinks 1 day is. For US Central Time, this means 363 "civil" days will have 24 hours, 1 day will have 23 hours, and 1 day will have 25 hours.

     

    However, '-24h' always means 24 hours prior regardless of time zone.

     

  • Thank you Rick for sharing the blog. How do I define the start of the month and the end of the month? I saw many articles talking about daily calculations. I want to build an analysis for monthly & yearly.