# Issue with last day of the month entry in a named query

**URL:** <https://forum.inductiveautomation.com/t/issue-with-last-day-of-the-month-entry-in-a-named-query/65024>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [October 10, 2022, 6:44pm UTC](https://forum.inductiveautomation.com/t/issue-with-last-day-of-the-month-entry-in-a-named-query/65024 "2022-10-10T18:44:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLG](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@BLG](https://forum.inductiveautomation.com/u/BLG)\
**Post date:** [October 10, 2022, 6:44pm UTC](https://forum.inductiveautomation.com/t/issue-with-last-day-of-the-month-entry-in-a-named-query/65024/1 "2022-10-10T18:44:02Z")

</div>

I have a monthly report set up in Ignition that uses a Named Query to populate daily totalized flow values. Since the totalized values are not written to the database until 1am of the next day, the Named Query is set up to log the values under the previous day's time stamp (see named query script below).

 ![NamedQuery](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd748c4863d5ebe52fca333cef9e0f99cd422571.jpeg)

The Report page includes pull-down components for the Month and the Year. Everything is working like it's supposed to except for the fact that the data for the last day of each month shows up under next month's filter (see pic below where 8/31/22 shows up under September and 9/30/22 is missing since it shows up under October). Any help would be much appreciated.

 ![Report](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/742f39a7e9e983df9fdaa99e726c99c6ddf6f32c.jpeg)

---

<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 10, 2022, 7:03pm UTC](https://forum.inductiveautomation.com/t/issue-with-last-day-of-the-month-entry-in-a-named-query/65024/2 "2022-10-10T19:03:04Z")

</div>

Try,

```auto
WHERE 
    date_part('month', DATEADD(hour, -1, sand_totals_mor.t_stamp)) = :Sel_Month 
    AND
    date_part('year', DATEADD(hour, -1, sand_totals_mor.t_stamp)) = :Sel_Year

```

i.e., Offset all the t\_stamps by one hour. That should work at month and year changes too.

* * *

Tip: post code using the \</\> button rather than (or as well as) screenshots to save us having to type it all out again!

---

<div class="post-metadata">

**Author:** ![BLG](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@BLG](https://forum.inductiveautomation.com/u/BLG)\
**Post date:** [October 10, 2022, 7:46pm UTC](https://forum.inductiveautomation.com/t/issue-with-last-day-of-the-month-entry-in-a-named-query/65024/3 "2022-10-10T19:46:25Z")

</div>

Thanks!
