# \[Help!\] Nested Query for Tag Historian Reporting

**URL:** <https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189>\
**Category:** Ignition\
**Created:** [August 5, 2024, 7:38pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189 "2024-08-05T19:38:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Lee1](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Steven\_Lee1](https://forum.inductiveautomation.com/u/Steven_Lee1)\
**Post date:** [August 5, 2024, 7:38pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189/1 "2024-08-05T19:38:12Z")

</div>

Hello.

The goal of my report is to display the duration (on) of a tag historian tag for the past week. Therefore, I have the parameters set up as:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/8/a84f6e20b7a4d57085f60ee1268e63c1becbce5b.png)

{StartDate} = now()  
{EndDate} = dateArithmetic(now(), -7, "day")

However, the report needs to only collect the data during shift hours which are 6PM to 6AM every day. How would I add this condition to my tag historian query in reports?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 5, 2024, 7:47pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189/2 "2024-08-05T19:47:20Z")

</div>

You can not "skip" time periods during a day with a tag history query binding.

You say this is a report, are you actually using the reporting module?

---

<div class="post-metadata">

**Author:** ![Steven\_Lee1](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Steven\_Lee1](https://forum.inductiveautomation.com/u/Steven_Lee1)\
**Post date:** [August 5, 2024, 7:56pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189/3 "2024-08-05T19:56:17Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/9/79c7a2d24dd6a23fa5ad83412b1959315f5f3e1d.png)  
Yes. I'm seeing if there is a way to do this using the nested queries in reporting

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 5, 2024, 7:57pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189/4 "2024-08-05T19:57:48Z")

</div>

I would suggest using a scripted data source. Then you can request only the time periods which you are interested in.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 5, 2024, 9:34pm UTC](https://forum.inductiveautomation.com/t/help-nested-query-for-tag-historian-reporting/94189/5 "2024-08-05T21:34:26Z")

</div>

You also have StartDate and EndDate backwards.
