- HMI Model: cmt3108XP
- EasyBuilder Pro Version: 6.09.02.338
- Serial Number or supplier: Maple Systems
Hello,
I am looking to export time stamps to a SQL database. Does EBPro support conversion to any standard “TIME” data format, such as seconds since January 1, 1970 (Unix time), or ‘YYYY-MM-DD HH:mm:ss’ (string)?
Side note, I will likely be using a macro to send the SQL Queries rather than data sampling since the program will need to be able to automatically go back and insert time data into rows several rows in the past.
Thanks,
Nathan
Hi @nanderson,
To send custom SQL queries, you will need to use the SQL Query object in “Advanced” mode as shown in this tutorial: Link. To submit a custom time format, I may recommend using a stored procedure in your database to generate the time. Then, the HMI can simply call that procedure to insert the new time entry.
Note: Here is a simple example application that will insert a unix timestamp into a SQL table via a stored procedure.
The table is configured as follows.
The stored procedure is designed as follows.
The function call in EBpro’s SQL Query object is shown below.
Oh, interesting- you’re using a stored procedure in MySQL. I’ll give it a try.
I was looking at using a JS script inside EB pro itself and trying to call something like:
var currentUnixTime = Math.floor((new Date()).getTime() / 1000); etc.
but the stored procedure seems to be a much better solution.