SQL Server jdbc - Time, milliseconds and microseconds.

2 visualizaciones (últimos 30 días)
Simone  Cavallarin
Simone Cavallarin el 4 de Sept. de 2017
Comentada: the cyclist el 16 de Nov. de 2017
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

Respuestas (1)

the cyclist
the cyclist el 4 de Sept. de 2017
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 comentarios
Manuel Dias
Manuel Dias el 16 de Nov. de 2017
Editada: Manuel Dias el 16 de Nov. de 2017
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 el 16 de Nov. de 2017
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 .)

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by