sqlwrite datatype error when trying to upload a table with a column of datetimes
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 PostgreSQL Native Interface에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!