prevent sqlwrite from rounding numbers

Hi everyone! I'm trying to write a table into a Access-database using sqlwrite and I have two problems.
1. Part of the table is a UNIX-timestamp which looks like this in the table: 1.570555200000000e+09 (Well it looks like this: 1.5706e+09 before double clicking it).
After the export to Access using sqlwrite it looks like this in the database: 1570560000
But it should look like this: 1570555200.
How can I prevent rounding the number? Rounding destroys the timestamp.
2. The rest of the table are numbers. After the export to Access they have different numbers after the point. Some have two and some have three numbers after the point.
Is it possible to specify the numbers after the point?
Many thanks in advance!!

답변 (1개)

Kiran Felix Robert
Kiran Felix Robert 2020년 10월 8일

0 개 추천

Hi Jan,
To avoiding rounding and data truncation by sqlwrite you can store the data as a string. This will also preserve the precision.
Kiran Felix Robert

댓글 수: 1

Luke Simonson
Luke Simonson 2021년 10월 1일
Is there an alternative to this? This doens't work properly when the database table already exists with number formats on specific columns.
I have a specific task where I am reading data from an SQL table, making some changes to a 4 columns (out of ~60 columns total) and rewriting them to the same table (appending new entries). However, many of the numberic columns are slightly off due to rounding.

댓글을 달려면 로그인하십시오.

카테고리

제품

질문:

2020년 9월 18일

댓글:

2021년 10월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by