# T\_stamp in SQLite DB

**URL:** <https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 11, 2023, 3:48pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882 "2023-06-11T15:48:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [June 11, 2023, 3:48pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/1 "2023-06-11T15:48:53Z")

</div>

I created a group transaction, save into SQLite Database, table name is TB001, with two tag , randomdouble1 & randomdouble2 .

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/9/19f414f5e1099a7b2c4da391d55d61959f92b966.png)

And when I query the table, and find the t\_stamp seems is integer value, not datetime.

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

I am trying to present the data in easy chart , so I drag a easy chart component, and add a DB pen.

Select SQLite DB and the my tag & t\_stamp.  
The message says" The type of time column 't\_stamp' is not a date."

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

I tried with MSSQL DB , same step, it works fine, the t\_stamp is datetime type.

How to do this in SQLite DB .  
I know there is a way to convert integer to datetime like

```auto
SELECT datetime(t_stamp/1000, 'unixepoch');

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2dfc81ba35c735d1d24f056d6cfe3d39284eb1e4.png)

But how to use this SQL query becomes another issue, seems DB pens only allow table selection, not query.

---

<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:** [June 11, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/2 "2023-06-11T15:55:44Z")

</div>

Judging by the column alignment in the screengrab of Resultset1 you are returning t\_stamp as a string.  
 ![t_stamp string](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/0/d054997b49ed0043bb6eb087960cd1495e32e799.png)

I suspect that your database table is not configured correctly.

---

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [June 11, 2023, 3:57pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/3 "2023-06-11T15:57:50Z")

</div>

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

Please refer to screenshot above, t\_stamp is like a integer.

It can convert to datetime with datetime(t\_stamp/1000, 'unixepoch')

If the DB is not configured correctly, can you help where to check.

---

<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:** [June 11, 2023, 4:12pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/4 "2023-06-11T16:12:50Z")

</div>

Try the [SQLite dump](https://www.sqlitetutorial.net/sqlite-dump/) command. Post the _Create_ section to let us see the structure.

---

<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:** [June 11, 2023, 5:07pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/5 "2023-06-11T17:07:31Z")

</div>

An even better solution would be to use a DB technology suited to production data. SQLite is made to hold configuration data, not production data. It is single-threaded and does not conform to modern SQL standards.

If you need free, use PostgreSQL or MariaDB.

---

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [June 12, 2023, 1:39am UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/6 "2023-06-12T01:39:12Z")

</div>

I query the t\_stamp data type from table browser, and noticed t\_stamp is text.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dc89163fd3cec7f6633d0bba000a83ecd9cff243.png)

So I manually create another table TB100 , with t\_stamp is datetime,create new Transaction Group and untick "Automatically create table" and select this new existing table , it works fine, I think issue is at the "Automatically create table" when create named query.

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

Anyway, I will go on this solution, thanks for your help.

And for my own curiousity , I checked tag history table which is also auto created, and the t\_stamp is integer, not sure why it works fine in Easy chart, probably there is convertion Ignition backend.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/5/9594df08e8f60b570aa229306b51c67713c33936.png)

---

<div class="post-metadata">

**Author:** ![Lina\_Su](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@Lina\_Su](https://forum.inductiveautomation.com/u/Lina_Su)\
**Post date:** [June 12, 2023, 1:47am UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/7 "2023-06-12T01:47:22Z")

</div>

Thanks Pturmel, I will use MSSQL for production , now I am doing test and training , thought SQLite would be easiest way to do without any futher application installation.

---

<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:** [June 12, 2023, 12:52pm UTC](https://forum.inductiveautomation.com/t/t-stamp-in-sqlite-db/74882/8 "2023-06-12T12:52:03Z")

</div>

> [@Lina\_Su](#):
>
> MSSQL for production , now I am doing test and training , thought SQLite

The two technologies are significantly different, because..."Microsoft"

You should definitely develop with MSSQL, otherwise you'll be refactoring queries during commissioning.
