I’m trying to use system.tag.storeTagHistory to write historical samples directly into the history database.
If I leave the “Timestamp” argument blank, it writes the timestamp in the database as now, in the “milliseconds since 1970” format.
If I add a Timestamp argument value in the function using the same timestamp format, I get an error. I have tried multiple standard timestamp formats for the argument and I can’t seem to get the function to execute.
What format for the Timestamp argument does the function expect?
The storeTagHistory function expects an array (in Jython terms, a list) of Date objects. system.date.now() returns a date object (which, technically, represents a date and time). To create an arbitrary Date object, you can use the system.date.* functions:
date = system.date.getDate(2018, 6, 29) #year, month (0 indexed!), day
date = system.date.setTime(date, 1, 37, 44) #hours, minutes, seconds
Then, you use that inside the storeTagHistory function you would have to wrap it in a list:
system.tag.storeTagHistory(<other arguments skipped>, [date])
The square brackets are the critical part.
Thank you!
I think I was trying to pass it a list of strings, so I’ll need to convert the strings to date objects then list those. I’ll try that.
Thanks.