# I dont can convert date time format with datetime.datetime.strptime

**URL:** <https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184>\
**Category:** Ignition\
**Created:** [March 1, 2018, 6:04pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184 "2018-03-01T18:04:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeraGarcia](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/geragarcia/32/18471_2.png) [@GeraGarcia](https://forum.inductiveautomation.com/u/GeraGarcia)\
**Post date:** [March 1, 2018, 6:04pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/1 "2018-03-01T18:04:30Z")

</div>

Hi, i dont can convert the date from this format: Mon Feb 26 08:00:00 CST 2018, to this one: 20180226 08:00:00.000

i’m traying with the datetime.datetime.strptime function but is not working.

Error: java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(UPDATE laboratorio\_PeletSQC\_Test SET ValorMuestra = ? WHERE ts\_muestra = ?, [7.0, Mon Feb 26 08:00:00 CST 2018], cnxLaboratorio, , false, false)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/52a2f306ced742141bbb7de1c93c043de444cd98.png)

Thanks Gerardo.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [March 1, 2018, 6:24pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/2 "2018-03-01T18:24:47Z")

</div>

You need to change your designer to read/write mode. Its in the Project menu.  
[HERE](http://forum.inductiveautomation.com/t/unable-to-insert-with-a-simple-select-statement/17145/5)

---

<div class="post-metadata">

**Author:** ![GeraGarcia](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/geragarcia/32/18471_2.png) [@GeraGarcia](https://forum.inductiveautomation.com/u/GeraGarcia)\
**Post date:** [March 1, 2018, 9:52pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/3 "2018-03-01T21:52:43Z")

</div>

Hi, zxcslo. Sorry i change the mode and this is the error message

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

Thanks Gerardo

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 1, 2018, 10:52pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/4 "2018-03-01T22:52:40Z")

</div>

Do you need the string conversion? The database driver will handle everything if you take datetime value from your first query, and use it directly in your update like:

```auto
for row in strRsConsulta:
  myTs = row[0]

...

argsSQL = [valor, myTs]
system.db.runPrepupdate(querySQL, argsSQL, cnxDB)

```

---

<div class="post-metadata">

**Author:** ![GeraGarcia](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/geragarcia/32/18471_2.png) [@GeraGarcia](https://forum.inductiveautomation.com/u/GeraGarcia)\
**Post date:** [March 1, 2018, 11:08pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/5 "2018-03-01T23:08:46Z")

</div>

Hi phillip.bow and zxcslo, both were right about the solution, evrything is ok, the code is working rigth now

the final code is:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/045a895f4f3be7d6f5373f0675b9d50358aabf19.png)

thanks Gerardo

---

<div class="post-metadata">

**Author:** ![GeraGarcia](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/geragarcia/32/18471_2.png) [@GeraGarcia](https://forum.inductiveautomation.com/u/GeraGarcia)\
**Post date:** [March 1, 2018, 11:29pm UTC](https://forum.inductiveautomation.com/t/i-dont-can-convert-date-time-format-with-datetime-datetime-strptime/17184/6 "2018-03-01T23:29:35Z")

</div>

Hi,

About this case i found this webs pages, i dont use this information but here is:

[http://python.6.x6.nabble.com/datetime-strptime-error-td1777642.html](http://python.6.x6.nabble.com/datetime-strptime-error-td1777642.html)  
[https://docs.python.org/3.3/library/datetime.html](https://docs.python.org/3.3/library/datetime.html)

> <https://stackoverflow.com/questions/17686954/python-time-conversion-into-proper-time-format>

Regards Gerardo
