SQL Datetime Locale

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 ?

The date script functions should be able to help out

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

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.

1 Like

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

Thanks @pturmel !!