4 Replies Latest reply on Oct 6, 2017 2:08 PM by Rick Davin

    SDK VBA: Changing OS Timezone as default

    bartmch

      Hi everybody, The VBA script I wrote to extract Pi Batches and then Pi Data will be running on multiple servers in different time zones. I'd like to convert any incoming user batch query into UTC time frame, get the batches, get the data for the batches and transform everything again into any user-specified time frame. I use "PITIME.inputstring = sUserInput" to convert any possible input string (eg "01-Jan-2017" or "*-10d") into a datetime. I can then use the datadiff("s", "PITIME.outputstring","1-Jan-1970") function to get a new pitime where I use UTCseconds to set the date into UTC. The issue is that, when creating this new PITIME to set the UTCseconds, it will automatically take the operating system default time zone (in my case "1-Jan-1970 04:00:00"). Should I correct newly created PITIMES from my timezone to the UTC+0 time zone? Or are there other ways like changing the default settings whereby the operating system time zone has been chosen? Any code snippet is more than welcome! Thanks

        • Re: SDK VBA: Changing OS Timezone as default
          Rick Davin

          Hi Bart,

           

          I have moved the location of your question.  You originally had it under the Learning space, which isn't necessarily a bad thing, but you also had it under the "Developing Applications with AF SDK" sub-space.  The reason for the move is because your question has nothing to do with AF SDK.

           

          Regards,

          Rick Davin

          • Re: SDK VBA: Changing OS Timezone as default
            bartmch

            Hey everybody, I'll rephrase my question to explain it better: Is there a way to change the time zone bias (eg. with pisrvr.pitimezone) so the timestamps will remain the same no matter in which time zone the SDK VBA code ran? Tried a few things but couldn't change the pitime.pitimeinfo.bias value. Any code snippet is more than welcome!Thanks! Bart

            • Re: SDK VBA: Changing OS Timezone as default
              Rick Davin

              Hi Bart,

               

              Sorry this question hasn't been receiving any attention.  I do have some questions to help clear things up for me.

               

              You have a Client PC running the VBA Script handling requests.  The requesting user enters a time, which is stored in a string variable named sUserInput.  I'm assuming sUserInput lacks any time zone offset or such time zone info within the string.  What time zone does sUserInput represent?  The requesting user's?  The Client PC?  Or the requested PIServer which could be in a different time zone?  Will the requesting user and Client PC always be in the same time zone?

               

              You may try reading up on Server.PITimeZoneInfo property.

               

              P.S. - This would be much easier to do if you were using VB.NET with AF SDK.