This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Trend evaluation
#4
This will log the highest value and respective date for the past 7 days.
Code:
daycount = 7
trendname = 'TEMP'

dates = {}
dates['start'] = os.date('*t')
dates['start'].day = dates['start'].day - daycount
dates['end'] = os.date('*t')

values = require('trends').fetch(trendname, dates, 86400, true)

table.sort(values, function(a, b)
  return a[2] > b[2]
end)

max = values[ 1 ]
time, value = unpack(max)
date = os.date('%F', time)

log(date, value)
Reply


Messages In This Thread
Trend evaluation - by stephan - 15.12.2023, 06:39
RE: Trend evaluation - by admin - 15.12.2023, 08:14
RE: Trend evaluation - by stephan - 15.12.2023, 12:23
RE: Trend evaluation - by admin - 15.12.2023, 12:49
RE: Trend evaluation - by stephan - 15.12.2023, 14:58

Forum Jump: