5 Replies Latest reply on Oct 12, 2016 4:05 PM by gregor

    Why the function ReadRaw only reads a string date with NOW included?

    Danepg

      LIBRARY: OPCHDAAutomation.

      CLASS:  OPCHDAItem

      FUNCTION:  ReadRaw(StartTime, EndTime, [NumValues As Long], [Bounds As Long])

       

      This function works great If  "StartTime="NOW-30H"  but if

      StartTime= #9/2/2016 11:22:23 AM#

      StartTime= #9/2/2016 11:22:23AM#

       

      Or any other string date in that format, we have debug on readRaw code line. We tried with  a variant equal the string StartTime   (Variant_StartTime= StartTime)  and the results are the same.

        • Re: Why the function ReadRaw only reads a string date with NOW included?
          Eugene Lee

          Hi Daniel,

           

          It works for me though. Make sure you didn't get the month and day reversed.

           

            • Re: Why the function ReadRaw only reads a string date with NOW included?
              Danepg

              Hi, thanks for answer

               

              What you have works for me too, but what we need is StartDate as a changing string date, that string is the output of another function.

              But, before that test, I am equaling StartDate  directly to the date and the result is debug on ReadRaw line.

              This is what we have:

              --------------------------------------------------------------------------------------------------------------------------------------------------

              StartDate = #9/5/2016 7:12:07 AM#
                  EndDate = "NOW"
                  Call HDA_TESTS(OSI_Tagname, StartDate, EndDate, i)

              *** THEN ON THE FUNCTION HDATEST *********
              Private Function HDA_TESTS(MyOSITag As String, sStartDate As String, sEndDate As String, Optional PenID As Integer)

                  Dim opcServer As New OPCHDAServer
                  Dim opcItem As OPCHDAItem
                  Dim opcValues As OPCHDAHistory
                  Dim opcValue As OPCHDAValue
                  Dim varStart As Variant, varEnd As Variant
                 
                  If PenID = 0 Then PenID = 1
                 
                  Call opcServer.Connect("OSI.HDA.1", "localhost")
                  Set opcItem = opcServer.OPCHDAItems.AddItem("\\pilocalserver\" & MyOSITag, 1)
                  varStart = sStartDate
                  varEnd = sEndDate
                    Set opcValues = opcItem.ReadRaw(varStart, varEnd)

              ------------------------------------------------------------------------------------------------------------------------------------------------------

               

              I believe varStart is date type on the ReadRaw function but If I have it like a variant, should work too, isnt it?