# Report History Question

**URL:** <https://forum.inductiveautomation.com/t/report-history-question/69009>\
**Category:** General Discussion\
**Tags:** ignition81\
**Created:** [January 25, 2023, 3:24pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009 "2023-01-25T15:24:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 25, 2023, 3:24pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/1 "2023-01-25T15:24:58Z")

</div>

Morning,

I am creating a report that pulls from a tag that has history. I want the start date to be 4:00 pm yesterday and the end date to be 4:am today.

I have reviewed the tag history binding video but I do not know how to write the expression for the parameters.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/769c407752e676d41f6cd256315d2697c2373dc5.png)

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

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 25, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/2 "2023-01-25T15:57:18Z")

</div>

I typically use the `midnight` expression function when setting a specific time. For the end time,

```auto
// This will take current date, set the time to midnight, and add 4 hours
// 4am today. The parameter in the now() function determines poll rate, 0 = poll off
addHours(midnight(now(0)), 4)

```

For start time, you could take the end date parameter, defined _before_ the start date parameter, and just add -12 hours.

```auto
addHours({End Date}, -12)
// or
addHours(midnight(now(0)), -8)

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 25, 2023, 4:03pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/3 "2023-01-25T16:03:40Z")

</div>

I would make one tweak to Daniel's suggestion, in order to make sure you get a 4am end date even across daylight savings time changes:

```auto
addHours(addDays(midnight(now(0)), 1), -20)

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 25, 2023, 4:06pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/4 "2023-01-25T16:06:44Z")

</div>

Wow, I never thought of daylight savings when using that 👀

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 25, 2023, 4:48pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/5 "2023-01-25T16:48:49Z")

</div>

[https://docs.inductiveautomation.com/display/DOC81/setTime](https://docs.inductiveautomation.com/display/DOC81/setTime)

`setTime(now(0), 4, 0, 0)`?

Honestly not sure how this would handle DST (or not).

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 25, 2023, 5:52pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/6 "2023-01-25T17:52:34Z")

</div>

Thank you all for the help.

I was able to test the two different methods.

For the test I simplified the search to today from 3:00 am to 4:00 am.

**I could not get the addHours to work.**

addHours(addDays(midnight(now(0)), 1), 3)

addHours(addDays(midnight(now(0)), 1), 4)

**I did get the setTime to work.**

setTime(now(0), 3, 50, 0)

setTime(now(0), 3, 55, 0)

How would I get the setTime to yesterdays date at 4:00 pm?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 25, 2023, 6:03pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/7 "2023-01-25T18:03:33Z")

</div>

The addHours works for me? As far as setTime goes..

```auto
setTime(addDays(now(0),-1), 3, 50, 0)

```

---

<div class="post-metadata">

**Author:** ![ahawes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ahawes/32/36337_2.png) [@ahawes](https://forum.inductiveautomation.com/u/ahawes)\
**Post date:** [January 25, 2023, 6:08pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/8 "2023-01-25T18:08:38Z")

</div>

I think i see my mistake.

I did not have a -1 for the previous date on the addHours solution.

Does the one you show below set the time the previous dat at 3:50 am? If that is the case if I needed the time to be 16:00 the day previous would it be 16,0,0?

setTime(addDays(now(0),-1), 3, 50, 0)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [January 25, 2023, 6:23pm UTC](https://forum.inductiveautomation.com/t/report-history-question/69009/9 "2023-01-25T18:23:30Z")

</div>

Yep, it uses 24hr, so 16 would be 4 pm on setTime.  
here is a link to the Ignition manual appendix on expression functions, which have explainations and examples for all expression functions. This is an invaluable resource 🙂 [Expression Functions - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Expression+Functions)
