# Insert statement date error

**URL:** <https://forum.inductiveautomation.com/t/insert-statement-date-error/10051>\
**Category:** Ignition\
**Created:** [May 22, 2015, 8:57pm UTC](https://forum.inductiveautomation.com/t/insert-statement-date-error/10051 "2015-05-22T20:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [May 22, 2015, 8:57pm UTC](https://forum.inductiveautomation.com/t/insert-statement-date-error/10051/1 "2015-05-22T20:57:15Z")

</div>

Hi, I need help inserting data to mysql db, I have a button with this code:

```auto
date = system.tag.read("Production/date")
user = "System"
notas = "ejemplo notas"
  
id = system.db.runPrepUpdate("INSERT INTO prueba (date, user, notas) " 
  + "VALUES (?, ?, ?)", [date, user, notas])

```

When I try to insert data to my DB I have this error:

```auto
java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO prueba (date, user, notas) VALUES (?, ?, ?), [Fri May 22 17:52:55 ART 2015,Good], System, ejemplo notas], , , false, false)

	caused by Exception: Error executing system.db.runPrepUpdate(INSERT INTO prueba (date, user, notas) VALUES (?, ?, ?), [Fri May 22 17:52:55 ART 2015,Good], System, ejemplo notas], , , false, false)
	caused by GatewayException: SQL error for "INSERT INTO prueba (date, user, notas) VALUES (?, ?, ?)": Data truncation: Incorrect datetime value: '¬í' for column 'fecha' at row 1
	caused by MysqlDataTruncation: Data truncation: Incorrect datetime value: '¬í' for column 'date' at row 1

```

I don’t know how to format the date to be a valid date to insert into my mysql db, I’m using now() in the tag.

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [May 22, 2015, 10:15pm UTC](https://forum.inductiveautomation.com/t/insert-statement-date-error/10051/2 "2015-05-22T22:15:33Z")

</div>

Change the 1st line to

```auto
date = system.tag.getTagValue("Production/date")
```

---

<div class="post-metadata">

**Author:** ![MoisesZV](https://avatars.discourse-cdn.com/v4/letter/m/e68b1a/32.png) [@MoisesZV](https://forum.inductiveautomation.com/u/MoisesZV)\
**Post date:** [May 22, 2015, 10:51pm UTC](https://forum.inductiveautomation.com/t/insert-statement-date-error/10051/3 "2015-05-22T22:51:30Z")

</div>

Thanks that solved my problem.
