# system.tag.storeTagHistory not able to store Timestamp as Required

**URL:** <https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121>\
**Category:** Ignition\
**Created:** [July 10, 2023, 7:45am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121 "2023-07-10T07:45:03Z")\
**Posts on this page:** 5\
**Page:** 1

<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 10, 2023, 7:45am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121/1 "2023-07-10T07:45:04Z")

</div>

Hi,  
I have tags for that historian is enabled and I want to write value with timestamp using system.tag.storeTagHistory, by using this value is storing in the database but timestamp is storing with current date & time and not the date time which I am provided from strtime.

system.tag.storeTagHistory("SQL\_Connection", "Test\_Tag\_Provider",["[Test\_Tag\_Provider]Test/Recipe1"], [Recipe1]],[strTime])

I want to write Recipe1 tag with Reipe1 value with timestamp as strTime that will be passed.

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [July 10, 2023, 7:58am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121/2 "2023-07-10T07:58:45Z")

</div>

I believe the table for storing data in the database uses a big Int data type for the timestamp value, you won't be able to store it as a string value there

---

<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 10, 2023, 8:59am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121/3 "2023-07-10T08:59:02Z")

</div>

Hi,  
I had converted the string to date format using  
datetime1 = system.date.parse(strTime, "yyyy-MM-dd HH:mm:ss" )

system.tag.storeTagHistory("SQL\_Connection", "Test\_Tag\_Provider",["[Test\_Tag\_Provider]Test/Recipe1"], [Recipe1]],[datetime1])

But I am getting the error as  
java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value 'Mon Jul 10 12:19:12 IST 2023' into type: class java.lang.Integer

---

<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 10, 2023, 9:29am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121/4 "2023-07-10T09:29:29Z")

</div>

from java.text import SimpleDateFormat  
Its worked

Thanks Hayden

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 10, 2023, 9:34am UTC](https://forum.inductiveautomation.com/t/system-tag-storetaghistory-not-able-to-store-timestamp-as-required/76121/5 "2023-07-10T09:34:14Z")

</div>

You should also be able to get it this way:

```auto
datetime1 = system.date.parse(strTime, "yyyy-MM-dd HH:mm:ss" ).time

```

By adding `.time` to the end, it will provide the date to millis which is a long integer datatype.
