PLCs : S7-1200
I’ve written a script to pull data from an SQL table and export it as a csv. My table has a ‘Timestamp’ column is defined as DATETIME(3). When I open the csv generated by my code, there are no fractional seconds digits in the Timestamp column. I have manually exported the data to .csv via mySQL workbench and the digits are retained as desired.
I’ve pasted an excerpt from my script below. Can anyone suggest a method for retaining the millisecond data? I notice there is a system.dataset.toExcel command. However, I have not had time to test this yet.
Thanks for looking.
# Build a SQL query. Note (`) character required for headers with spaces. query = system.db.runQuery("SELECT Timestamp, `CF Number`, `Roll Number`, `Roll Diam (mm)`, `Log Posn`, `Width Posn (mm)`, `A112ZT001 (mm)`, `A112ZT002 (mm)`, `Thickness (mm)` FROM data_fthick") # Get the data from the SQL DB results = system.dataset.toDataSet(query) # Use system.dataset.toCSV to turn the dataset into a CSV string sqlData = system.dataset.toCSV(dataset = results, showHeaders = True, forExport = 0) # Append the data to the file system.file.writeFile(filePath, sqlData, 1)