SQL Server jdbc - Time, milliseconds and microseconds.

2 次查看(过去 30 天)
Hi,
I have a sql query and everything works fine, but matlab during the import lose all the numbers after the seconds. Inside the DB I have 7 numbers after the seconds that are complitely lost in Matlab.
SQL --> 07:55:04.1621280
MATLAB--> 07:55:04
I have attached two screen shots, one from the DB and one frome the "CURS" in ML.
Could anyone give me any suggestion on how can I keep all the microseconds?
This page gave me some information but is not usefull for SQL:
Many thanks
s

回答(1 个)

the cyclist
the cyclist 2017-9-4
Are you sure it is not just an issue with how the number is being displayed? It may have the full precision.
I generally return data in cell array format, and have no problem. Perhaps try that?
  5 个评论
Manuel Dias
Manuel Dias 2017-11-16
编辑:Manuel Dias 2017-11-16
Hi i stumbled at the same difficulty and i found one way to pass it. Use
Select time_collumm, DATEPART( millisecond,time_collum) as milliseconds from table_name
This will import to matlab a table with 2 collums. One with hh:mm:ss and the other with milliseconds. Now just convert the milliseconds to char and then add to the time part.
If you need more information about this solution you can find it here: https://docs.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql
the cyclist
the cyclist 2017-11-16
Interesting idea. Along these lines, you could also perform the character concatenation within the SQL query itself, and just return the one column you need. (In postgres you concatenate with .)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by