sqlwrite only writes 6 digits to Access Database
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to write an Excel date code to an Access database in the format: 44798.6912268518
but when I open the Access database, the date code is written as 44798.7.
Is there a way to write more than 6 digits to an Access database without changing the data type to a string?
0 Kommentare
Antworten (1)
Rahul
am 7 Nov. 2024 um 9:48
I understand that currently while accessing data from database, you are obtaining the number in a short format. You can consider defining 'format long' before writing the data which can consider approximately 15 decimal places for double-precision numbers. Here is an example:
% I have taken 'conn' and 'tablename' as variables for connection with the database, can be adjusted
% Set the display format to long
format long
dateCode = 44798.6912268518;
data = table(dateCode, 'VariableNames', {'yourFieldName'});
sqlwrite(conn,tablename,data)
Another approach can be to use the 'vpa' function provided by the Symbolic Math Toolbox which enables to define number of significant decimal places required. Here is an example:
dateCode = vpa(44798.6912268518, 30); % Here I have taken 30 as an example for required decimal places
data = table(dateCode, 'VariableNames', {'yourFieldName'});
sqlwrite(conn,tablename,data)
You can refer to the following MathWorks documentations to know more about these functions:
Hope this helps! Thanks.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!