# SQL Datetime Locale

**URL:** <https://forum.inductiveautomation.com/t/sql-datetime-locale/37378>\
**Category:** Ignition\
**Tags:** database, ignition80\
**Created:** [August 4, 2020, 6:02pm UTC](https://forum.inductiveautomation.com/t/sql-datetime-locale/37378 "2020-08-04T18:02:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [August 4, 2020, 6:02pm UTC](https://forum.inductiveautomation.com/t/sql-datetime-locale/37378/1 "2020-08-04T18:02:35Z")

</div>

Hello All,

We are doing database table read/write thru scripting. Dates were also created in string format when required to add into the database. Hence, the date looked something like `'yyyy-MM-dd hh:mm:ss'`. Now, we have another project where the SQL server and Ignition is running under Fr(French) locale. When, I try to run update query with the same format as one above, it throws an error and expects the date to be in this format - ‘yyyy-dd-MM hh:mm:ss’.

What is the best way to pass date time with not using Named Queries ?  
Edit : may be if I can pass java.util.date or timestamp ?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 4, 2020, 6:39pm UTC](https://forum.inductiveautomation.com/t/sql-datetime-locale/37378/2 "2020-08-04T18:39:46Z")

</div>

The date script functions should be able to help out

```auto
today = system.date.now()
print system.date.format(today, "yyyy-dd-MM hh:mm:ss")

```

---

<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:** [August 4, 2020, 7:52pm UTC](https://forum.inductiveautomation.com/t/sql-datetime-locale/37378/3 "2020-08-04T19:52:51Z")

</div>

> [@kaushik.shah](#):
>
> with not using Named Queries ?

Ideally, you should drop your aversion to Named Queries. They are almost always the _Right Answer_™. If you must do dynamic stuff that is difficult in a static SQL statement, use the system.db.\*Prep\*() functions to pass values to your DB without converting to/from strings.

---

<div class="post-metadata">

**Author:** ![kaushik.shah](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@kaushik.shah](https://forum.inductiveautomation.com/u/kaushik.shah)\
**Post date:** [August 4, 2020, 7:56pm UTC](https://forum.inductiveautomation.com/t/sql-datetime-locale/37378/4 "2020-08-04T19:56:08Z")

</div>

> [@pturmel](#):
>
> If you must do dynamic stuff that is difficult in a static SQL statement, use the system.db._Prep_()

That is what I ended up doing. Just parsed string date with system.date.parse()

Thanks @pturmel !!
