# Named Query with where clause of datetime not working properly

**URL:** <https://forum.inductiveautomation.com/t/named-query-with-where-clause-of-datetime-not-working-properly/76371>\
**Category:** Ignition\
**Created:** [July 14, 2023, 11:20am UTC](https://forum.inductiveautomation.com/t/named-query-with-where-clause-of-datetime-not-working-properly/76371 "2023-07-14T11:20:29Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [July 16, 2023, 10:21am UTC](https://forum.inductiveautomation.com/t/named-query-with-where-clause-of-datetime-not-working-properly/76371/8 "2023-07-16T10:21:48Z")

</div>

Sorry for the late reply,  
I am using MySQL Workbench 8.0.33

For below issue I am trying to find a solution.

> [@TagHistory and History Enabled storing duplicate values](https://forum.inductiveautomation.com/t/taghistory-and-history-enabled-storing-duplicate-values/76301/1):
>
> Hi, I am reading the data from restAPI and storing the data with timestamp which is coming from API with storeTagHistory. and when last data is recieved I write to the tag, As I write to the tag the value gets stored in database with current time. But the last value I had already saved using storeTagHistory and I am having a duplicate values with current time. I am trying to restrict the last value getting saved after writing it to the tag. As this tag have read and write option I cannot p…

I was thinking of creating 2 tags for same variable, 1 for reading and 1 for writing and while saving the data in to the database I will have 2 tagID, for this reason I am trying to find a way like this.

> [@Write to tag and set timestamp?](https://forum.inductiveautomation.com/t/write-to-tag-and-set-timestamp/60100/22):
>
> When reading data from API and writing to the database using storeTaghistory and at the end writing the value to tag As tag have the historian enabled so again a new value is stored in the database with current time. We cannot disabled the history as we are writing to that tag and storing in the database, only concern is when writing the last value to tag it save into the database

---

_[View the full topic](https://forum.inductiveautomation.com/t/named-query-with-where-clause-of-datetime-not-working-properly/76371)._
