Wondering if a Timestamp of a tag can be forced using scripts or any other methods?
I want to read a timestamp from OPC, separate to another Boolean value from OPC.
These 2 correlate, I want to write the Boolean to a memory tag, and want to force its timestamp to be the timestamp I read over OPC.
I know this can be done using a module and would need this developed, just looking for an alternative. When I do a system tag write it creates a Custom Timestamp but I don’t believe this would be applied to an alarm, it will use actual tag timestamp.
You can try writing a
QualifiedValue directly; something like:
from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue paths = ["path/to/tag"] values =  qvs = [BasicQualifiedValue(v) for v in values] for qv in qvs: qv.timestamp = system.date.getDate(2020, 11, 25) system.tag.writeBlocking(paths, qvs)
“from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue
paths = [“path/to/tag”]
values = 
qvs = [BasicQualifiedValue(v) for v in values]
for qv in qvs:
value.timestamp = system.date.getDate(2020, 11, 25)
Thanks @PGriffith, This worked, Only thing I had to change was value.timestamp to qv.timestamp.
One to note for anyone else needed this is January is month 0.
Hi Paul, Will it work if the value didn’t changed. But there might be different timestamp.
You could use the same method, you’ll just want to read the tag before you write it to leave the value unchanged. That does introduce a potential race (the value could change between your read and subsequent write) but is likely safe enough.
Thank you Paul…
Paul, out of curiosity, if this tag we just wrote a value (and timestamp) to is being historized, does the tag historian use this timestamp as the t_stamp to store in the Historian database? Or does the historian use it’s own now() value when inserting upon evaluating?
In 7.9 and previous, there were separate notions of timestamp sources, but as far as I know, in 8.0+ the timestamp is basically always calculated in the historian, not ‘trusted’ from the value.
Darn. This kindof means I’m out of luck. If I import raw tag data from a CSV file using system.tag.storeTagHistory function, I can specify the timestamp…but I lose out on the deadband optimization the Historian provides so I end up storing way more data than I need. If I instead write to the tag’s value and timestamp, I gain the deadband and alarm functionality, but the historian won’t use my timestamp.