Skip to main content
1-Visitor
April 2, 2021
Solved

Timestamp time difference

  • April 2, 2021
  • 1 reply
  • 3471 views

Hi I want to get the difference between the timestamp value logged when a property updates on a thing. The thing has an valuestream. Do I need to write a service for this? Which snippets would I use? Or is there an existing service which would do this so it can be displayed in a mashup. Thanks in advance.

Best answer by PaiChung

If you have a subscription on the property data change, you'll get new and old VTQ, subtract the new and old Time (T part of VTQ) and then convert the milliseconds to the time you want.

1 reply

22-Sapphire I
April 5, 2021

Depending on how and when you need it, when a property updates, if you subscribe to the datachange, you'll have new and old VTQ of the property as the input into the datachange subscription

else you'd have to pull from the value stream

Carl9851-VisitorAuthor
1-Visitor
April 5, 2021

I need to time difference on the timestamp when the property updates say property is good part, timestamp is 2021-04-5-16:00.00 then next timestamp is 2021-04-5-16:01.00 so time difference is 1 minute

PaiChung22-Sapphire IAnswer
22-Sapphire I
April 5, 2021

If you have a subscription on the property data change, you'll get new and old VTQ, subtract the new and old Time (T part of VTQ) and then convert the milliseconds to the time you want.