# How to INSERT SQLite Timestamp in human date not UNIX timestamp form

**URL:** <https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346>\
**Category:** General\
**Created:** [10 September 2019 06:01 UTC](https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346 "2019-09-10T06:01:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yortz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yortz/32/9480_2.png) [@Yortz](https://discourse.nodered.org/u/Yortz)\
**Post date:** [10 September 2019 06:01 UTC](https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346/1 "2019-09-10T06:01:34Z")

</div>

I try to insert human date coupled with my data in table but always get error like this  
 ![Screenshot_2019-09-10%20Node-RED%20wichet%20trueddns%20com](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3a61e14416ed17051b709f80776b3fc6a4890b04.png)  
my flow

```auto
[{"id":"df7c4ab5.c42d2","type":"inject","z":"9c4e2b4a.f3bf3","name":"CREATE EMETER TABLE","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":930,"y":900,"wires":[["72c01c7d.4f10e4"]]},{"id":"22d9db3.1c61e24","type":"inject","z":"9c4e2b4a.f3bf3","name":"INSERT INTO at 00:01","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"01 00 * * *","once":false,"onceDelay":0.1,"x":930,"y":940,"wires":[["cf620389.7858e"]]},{"id":"cf620389.7858e","type":"simpletime","z":"9c4e2b4a.f3bf3","name":"Get Time","x":1140,"y":960,"wires":[["a7b3b9e9.312b6"]]},{"id":"a7b3b9e9.312b6","type":"function","z":"9c4e2b4a.f3bf3","name":"","func":"var current = flow.get(\"current\")\nvar voltage = flow.get(\"voltage\")\nvar power = flow.get(\"power\")\nvar energy = flow.get(\"energy\")\nvar time = msg.mytimes;\nvar date = msg.myyear+\"-\"+msg.mymonthn+\"-\"+msg.mydom\n\nvar newMsg = {\n \"topic\": \"INSERT INTO emeter VALUES ( \" + date + \", \" + time + \", \" + voltage + \",\" + current + \", \" + power + \", \" + energy + \")\"\n}\n\nreturn newMsg;\n","outputs":1,"noerr":0,"x":1290,"y":960,"wires":[["d0b2364b.efb0c"]]},{"id":"72c01c7d.4f10e4","type":"function","z":"9c4e2b4a.f3bf3","name":"","func":"msg.topic = \"CREATE TABLE emeter( date DATE NOT NULL PRIMARY KEY, time TIME NOT NULL, voltage FLOAT NOT NULL, current FLOAT NOT NULL, power INT NOT NULL, energy INT NOT NULL)\"\nreturn msg;","outputs":1,"noerr":0,"x":1290,"y":920,"wires":[["d0b2364b.efb0c"]]},{"id":"d0b2364b.efb0c","type":"sqlite","z":"9c4e2b4a.f3bf3","mydb":"33e1f2a3.618cee","sqlquery":"msg.topic","sql":"","name":"Electricity Usage KM.10","x":1600,"y":960,"wires":[["a92960d4.3b0e4","3e15ae3d.150b0a"]]},{"id":"a92960d4.3b0e4","type":"debug","z":"9c4e2b4a.f3bf3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1850,"y":960,"wires":[]},{"id":"33e1f2a3.618cee","type":"sqlitedb","z":"","db":"/tmp/sqlite","mode":"RWC"}]

```

Thanks:)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [10 September 2019 06:14 UTC](https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346/2 "2019-09-10T06:14:10Z")

</div>

You need to insert them as a string:

```auto
VALUES ( " + date + ", " + time + "...

```

```auto
VALUES ('" + date + "', '" + time + "'...

```

---

<div class="post-metadata">

**Author:** ![Yortz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yortz/32/9480_2.png) [@Yortz](https://discourse.nodered.org/u/Yortz)\
**Post date:** [10 September 2019 06:17 UTC](https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346/3 "2019-09-10T06:17:38Z")

</div>

It's work! Thanks a lot.😃

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [10 September 2019 08:58 UTC](https://discourse.nodered.org/t/how-to-insert-sqlite-timestamp-in-human-date-not-unix-timestamp-form/15346/4 "2019-09-10T08:58:52Z")

</div>

Not storing timestamps in UNIX format will negate any aggregate time related queries. You should be aware of this.
