MATLAB: Am I unable to get millisecond data of a timestamp in the database using Database Toolbox 3.11 (R2012a)

databaseDatabase Toolboxmillisecondstimestamp

I am trying to extract the timestamp from a given database using JDBC driver. The time data is captured as a cell array in the format HH:MM:SS. However, the time data contained milliseconds in the format HH:MM:SS.xxxxxx. I know this is not a limitation of cell array.

Best Answer

For troubleshooting, try the following:
Curs = exec(conn, 'select <timestamp_col_name> from <timestamp_table_name> ')
Curs = fetch(curs);
A = attr(curs);
The JDBC driver should return A(1).typeValue as 93 for database toolbox to process it correctly and convert it to a string.
If it returns the value 92, it is a known limitation of java.sql.Time class which is what the code '92' stands for. The driver converts Database 'Time' object to a 'java.sql.Time' object which does not handle milli and micro seconds.
One way to work around this is to write custom Java code to use the 'getTimestamp' method and then convert it into a time string as attached. Note that this is just an example and you will have to review the code and make necessary changes to fit his requirements.