# Tag History Binding (Round tstamp)

**URL:** <https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919>\
**Category:** Ignition\
**Created:** [October 6, 2022, 8:08pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919 "2022-10-06T20:08:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_Medley](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Brad\_Medley](https://forum.inductiveautomation.com/u/Brad_Medley)\
**Post date:** [October 6, 2022, 8:08pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919/1 "2022-10-06T20:08:34Z")

</div>

Can you Round Tag History timestamp when binding to a table, or do we need to do a query against the actual partition?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/95339e02eb1e46e9c573f6131ba480875868ac66.png)

Looking to round the t\_stamp to the nearest hour and add the shift to it. Would Scripting be easier to do this?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/11b93aaabda4487ce16be591edc115fb9b0bd181.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2022, 8:13pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919/2 "2022-10-06T20:13:50Z")

</div>

> [@Brad\_Medley](#):
>
> ... and add the shift to it.

What exactly does this mean? Add it to what? Do you mean "add a new column with the shift number calculated from the times"? What are the shift times?  
What is to happen if the time is 07:58 but it's rounded to 08:00?

You need to write a proper specification before you start to code!

---

<div class="post-metadata">

**Author:** ![Brad\_Medley](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@Brad\_Medley](https://forum.inductiveautomation.com/u/Brad_Medley)\
**Post date:** [October 6, 2022, 8:33pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919/3 "2022-10-06T20:33:41Z")

</div>

Thanks for the advice. Definitely not a professional coder. Teaching myself what I can. I will work on getting a project spec.

What I was thinking I could do is round the t\_stamp, and I would be able to join the two tables together allowing me to provide shift data through charts and export functionality.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8f232e2d236a082677bd7259ec784ec0ffbc1d4f.png)

Currently I am performing the work through a transaction group, but wasn't sure if there was a better route to accomplish my goal.

---

<div class="post-metadata">

**Author:** ![jeremy.lecoutre](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@jeremy.lecoutre](https://forum.inductiveautomation.com/u/jeremy.lecoutre)\
**Post date:** [October 6, 2022, 9:05pm UTC](https://forum.inductiveautomation.com/t/tag-history-binding-round-tstamp/64919/4 "2022-10-06T21:05:11Z")

</div>

You can use this expression on start date, to round hours.

```auto
dateArithmetic(toDate(dateFormat(now(0), 'yyyy-MM-dd HH:00:00')),-168,"hour")

```

Change query mode to Periodic and set it to 1h.

Choose an aggregate wich match with your need, "LastValue" i think in your case.
