Skip to main content
1-Visitor
April 2, 2021
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
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.

8 replies

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

Translate
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

Translate
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.

Translate