sqlwrite datatype error when trying to upload a table with a column of datetimes
Mostrar comentarios más antiguos
Hi - I'm getting a checkDataTypes error when I try and upload a table into postgreSQL with a column of dates saved as datetimes.
I create a timetable, turn it into a table with timetable2table(). Then I try and upload that new table into PostgreSQL.
Here is a version of the code.
TimeTbl = timetable([1;2;3], 'RowTimes', datetime('1/31/2022'):calmonths(1):datetime('3/31/2022'), ...
'VariableNames', {'Var1'});
Tbl = timetable2table(TimeTbl, "ConvertRowTimes", true);
Tbl.Properties.VariableNames{1} = 'Date';
conn = postgresql(username, password, 'DatabaseName', 'testdb');
sqlwrite(conn, 'testdb', Tbl);
Here's the error I'm getting:
Error using database.postgre.connection/sqlwrite>checkDataTypes (line 315)
Date column value must be a numeric array or cell array of numeric scalars.
Error in database.postgre.connection/sqlwrite (line 155)
data = checkDataTypes(typNames,typeCategories,data);
Thanks! Bill
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre PostgreSQL Native Interface en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!