Menu

GetDateTimeAt return wrong month

2021-09-16
2021-09-21
  • Fredrik Gustavsson

    Reading a DATE_AND_TIME variable from a DB (S7-300), the start address for this variable is at index 4 to 11 in the buffer array. The strange thing is that the GetDateTimeAt return the same except that the month is wrong.
    The actual value when reading the data was 2021-09-16 17:45:47...

    VB VisualStudio 2019, Snap 1.4.2 64bit

    Debug.Print(Hex(Buffer(4)).ToString) 'returns 21
    Debug.Print(Hex(Buffer(5)).ToString) 'returns 9
    Debug.Print(Hex(Buffer(6)).ToString) 'returns 16
    Debug.Print(Hex(Buffer(7)).ToString) 'returns 17
    Debug.Print(Hex(Buffer(8)).ToString) 'returns 45
    Debug.Print(Hex(Buffer(9)).ToString) 'returns 47
    Debug.Print(Buffer(10).ToString)
    Debug.Print(Buffer(11).ToString)

    Debug.Print(S7.GetDateTimeAt(Buffer, 4).ToString) 'returns 2021-08-16 17:45:47

     
  • Fredrik Gustavsson

    This has been discussed before here

     
  • Fredrik Gustavsson

    Downloaded Sharp7 and made a new project in C# Visual studio 2019. Now the GetDateTimeAt works as it should. I guess the snap7.net.dll for VB from the 1.4.2 package is not compiled with the latest code? That dll is not used in C#.

     
  • Fredrik Gustavsson

    Now I have built a new snap7.net.dll with VS2019 that I can use with my VB-code and the GetDateTimeAt is now working in VB also. I followed the instructions in this thread:
    https://sourceforge.net/p/snap7/discussion/general/thread/79e9387c/

     

Log in to post a comment.

MongoDB Logo MongoDB