system.tag.queryTagHistory Invalid Date Format

In a runScript expression I am using the system.tag.queryTagHistory to pull data from my historian table and am using a date range selector. The queryTagHistory doesn’t like the format of the startdate and enddate of the date range selector and gives me the error "Cannot coerce value into type class java.util.Date. Did I miss something, they should both be of data type Date?

Hi,

Maybe if you post your script we can get a better idea of what’s going on. I just did a quick test that worked fine, so you might want to double check that you’re using the right properties:

dr=event.source.parent.getComponent("Date Range") res=system.tag.queryTagHistory(paths=['SampleTag'],startDate=dr.startDate,endDate=dr.endDate) event.source.parent.getComponent("Table").data=res

Regards,

here is my script:
runScript(“system.tag.queryTagHistory(‘TAC/JP/EQUIPMENT/MOTORS/M 207/Avg_Current_Scaled’,’{Root Container.Date Range.startDate}’,’{Root Container.Date Range.endDate}’,-1,‘Average’,‘Wide’)”)

Hi,

I missed that you mentioned a runScript expression. With the example you provided, the main problem is that you can’t reference properties in a string like that, you need to concatenate them in:

runScript("system.tag.queryTagHistory('[TAC/JP/EQUIPMENT/MOTORS/M 207/Avg_Current_Scaled]','"+{Root Container.Date Range.startDate}+"','"+{Root Container.Date Range.endDate}+"',-1,'Average','Wide')")

Also note that I added square brackets around your tag path, as it’s supposed to be a list of paths.

On a side note, I think that most places where you would do this you could probably just use the tag history binding instead. Is it not available in this case? Or do you have another reason for using runScript? At any rate, it should work as written above.

Regards,