# Tag history on a table

**URL:** <https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270>\
**Category:** General Discussion\
**Created:** [December 6, 2018, 8:56pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270 "2018-12-06T20:56:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [December 6, 2018, 8:56pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/1 "2018-12-06T20:56:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [December 6, 2018, 11:00pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/2 "2018-12-06T23:00:35Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [December 7, 2018, 1:47am UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/3 "2018-12-07T01:47:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jasko](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jasko](https://forum.inductiveautomation.com/u/jasko)\
**Post date:** [December 7, 2018, 8:38am UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/4 "2018-12-07T08:38:15Z")

</div>

Hi,

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](https://docs.inductiveautomation.com/display/DOC79/system.date.now)

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [December 7, 2018, 4:31pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/5 "2018-12-07T16:31:30Z")

</div>

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()):  
event.source.parent.getComponent(‘EndDate’).dateValue=system.date.now()

Still learning this script…

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 7, 2018, 4:45pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/6 "2018-12-07T16:45:40Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![grietveld](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/grietveld/32/6984_2.png) [@grietveld](https://forum.inductiveautomation.com/u/grietveld)\
**Post date:** [December 7, 2018, 4:50pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/7 "2018-12-07T16:50:13Z")

</div>

> [@shibubalaji](#):
>
> if(event.source.parent.getComponent('EndDate').dateValue \> system.date.now()):  
> event.source.parent.getComponent('EndDate').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.

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [December 7, 2018, 9:00pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/8 "2018-12-07T21:00:21Z")

</div>

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():  
dateSelector.date=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!!!

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [December 10, 2018, 2:05pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/9 "2018-12-10T14:05:21Z")

</div>

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.

```auto

```

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

```

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

```auto
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.
```

---

<div class="post-metadata">

**Author:** ![shibubalaji](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shibubalaji/32/9165_2.png) [@shibubalaji](https://forum.inductiveautomation.com/u/shibubalaji)\
**Post date:** [December 11, 2018, 8:26pm UTC](https://forum.inductiveautomation.com/t/tag-history-on-a-table/21270/10 "2018-12-11T20:26:21Z")

</div>

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…
