I wanted to sharre this here for 2 reasons.
1., incase someone else is looking for something similar (as i was)
2. incase there is room for improvement/optimization
i built this script as a table so i can poll the history of some tags from tag historian database based on the dates in a trend slider. this script is in the table of the data and drops it into a new table that is on the forefront.
I did this because grabbing the dataset directly from the trend was giving me min/max values not closest value like i wanted.
It allows converting data between metric/imperial values as well and then i can export it.
This is for Pressure and temperature. As you can see, the values in the database for history are saved as Metric.
Metric property is 0 for metric, 1 for imperial, comes from a dropdown list.
Also the Date and the time are separated in the formatting.
if event.propertyName == "data" or event.propertyName == "metric": # bring dataset from this table into script dats = event.source.data # metric or imperial? if metric do this if event.source.metric == 0: newhdr = ["yyyy-mm-dd", "hh:mm:ss", "Pressure (kPa)", "Temp. (degC)"] pconv = 1.0 tcon1 = 1.0 tcon2 = 0.0 # metric or imperial? if imperial do this if event.source.metric == 1: newhdr = ["yyyy-mm-dd", "hh:mm:ss", "Pressure (psi)", "Temp. (degF)"] pconv = 0.145033 tcon1 = 1.8 tcon2 = 32.0 newdat =  # get the data from the old dataset, modify it, and then place it into the new dataset row by row for row in range(dats.rowCount): a = system.date.format(dats.getValueAt(row, 0), "yyyy-MM-dd") b = system.date.format(dats.getValueAt(row, 0), "hh:mm:ss") c = dats.getValueAt(row, 1) cc = (c * pconv) d = dats.getValueAt(row, 2) dd = ((d * tcon1) + tcon2) newdat.append([a, b, cc, dd]) # build the new dataset with headers and data dataset = system.dataset.toDataSet(newhdr, newdat) # this sends the new modified dataset to the new table on top of the master table (this is the master table) event.source.parent.getComponent('Table2').data = dataset