Ignition Database datetime data input to View's param

Hello,everyone,

I’m working on a project in Ignition where I retrieve a date and time value from a database and store it in a view parameter (view.params.datetime). However, when I retrieve this value, its format changes to something like "Tue Nov 05 2024 11:30:00 GMT+0900 (JAPAN Standard Time)". Additionally, the data type is recognized as unicode.

My goal is to take this view parameter (with its formatted date and time) and insert it into another database table. Unfortunately, because the format is not directly compatible with the database’s datetime format, I’m having trouble with the insertion.

I’ve tried various approaches to reformat this unicode date string to match the datetime format required by my database (yyyy-MM-dd HH:mm:ss), but I'm still encountering errors.

Does anyone know a reliable way to convert this unicode date string from the view parameter into a compatible datetime format for database insertion? Or is there a recommended method in Ignition to handle this type of timezone-stamped date string?

Thanks in advance for any advice or suggestions!

Standard practice is to store date and time as DATETIME type in the database. Don't convert it to a string until you need to display it to a human. In addition, saving in UTC will avoid lots of problems with timezones and daylight saving.

Show us your query and someone may have suggestions for improvement. See Wiki - how to post code on this forum.

1 Like