Skip to main content
Apr 2, 2021 6:44 PM UTC
Solved

Timestamp time difference

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.

PaiChungAnswer
Apr 5, 2021 9:19 PM UTC

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.

8 replies

Apr 5, 2021 1:08 PM UTC

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

Carl985Author
Apr 5, 2021 3:50 PM UTC

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

PaiChungAnswer
Apr 5, 2021 9:19 PM UTC

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.