Tag history on a table

I have a table and its data accessed through tag history with selected historical tag. t_stamp for each of this tag is automatically pulled in to the table and I would like to limit the t_stamp to be less than now() or the current date. Because, historian wont be having any tag value that is greater than now(). How do I do that? Currently, I have two spinner with start date and end date which filter the table data between the selected date, but it will not restrict me to select the date which is greater than todays date.
Any idea to overcome this situation?

maybe try a property change script on the spinner and check if the selected date is > than now() and if it is then write the date to now()

1 Like

python scripting will not accept this now() for system time…
I know the below script is not correct , please do share how to write the script in event handler…

if (event.source.parent.getComponent(‘EndDate’).dateValue)=> now():
EndDate= now()
Is this syntax correct for this? note:- EndDate is the name of the spinner.


the now() function in python scripting should be called like this system.date.now().
Fore mor info see: https://docs.inductiveautomation.com/display/DOC79/system.date.now


Hello Jasko, thanks for the reply.
Some reason it is not accepting the script that I wrote. I gives an error mismatched input INDENT …
(note:- ENdDate is the name of the spinner)

what is wrong with the script…can any one help me on this…

if(event.source.parent.getComponent(‘EndDate’).dateValue > system.date.now()):

Still learning this script…

The line after your ‘if’ statement has to be indented. White space matters in Python.

I can’t tell how your script is formatted because it gets mangled by the forum unless you type 3 back quote characters (`) on the line before the script, and 3 again after.

Here’s how it should look. I also made a minor adjustment to eliminate calling getComponent() 2 times.

dateSelector = event.source.parent.getComponent('EndDate')
if dateSelector.dateValue > system.date.now():

I’m not sure if its from copying the data over or if its the error, but make sure to indent the second line. The scripts use tabs/indents instead of brackets for nested code.

1 Like

Johson, Thanks for the reply and I ran with your script and is giving another error called no date attribute!!!
My date format is
Dec 6, 2018 7:02 AM and here is my code
dateSelector = event.source.parent.getComponent(‘EndDate’)
if dateSelector.dateValue > system.date.now():

Traceback (most recent call last):
File “event:actionPerformed”, line 2, in
AttributeError: ‘com.inductiveautomation.ignition.common.script.Scr’ object has no attribute ‘date’

some reason, system.date.now() is not accepting!!!

When posting script on the forum please include 3 back quotes on a line before your script and again after your script. This will preserve your formatting and make it more readable.

The error is not caused by calling system.date.now. 

dateSelector = event.source.parent.getComponent(‘EndDate’)
if dateSelector.dateValue > system.date.now():

On the 2nd line you are checking the attribute "dateValue" of the date selector component, but on the 3rd line you are trying to assign system.date.now() to an attribute named "date", which does not exist.

Look carefully at the script that I posted earlier and you can see that it is different than the one you posted.
1 Like

Thanks JG… I was using spinner as well as Date picker. One of them has dateValue and the other one has date and property. Probably that would have caused the issue. Any ways, I simply overcome this issue through an expression with out any script and working fine… Thanks to all for the help…