How to: value(now) - value(some time ago) to see Difference over time?

Iam searching for the same, does anybody know how to calculate such info ?
For IOT, its a basic info, I cannot beleive its not possibile a coorect caluclation of ON time.