exec & fetch commands (Problem with data format?)

3 views (last 30 days)
J
J on 8 Aug 2015
Hi, I'm having some problems importing a time variable from my database into MATLAB. I think the problem might have something to do with the format of the time parameter which is:
HH:MM:SS.MS
Example:
00:04:13.46
H = Hour, M = Minute, S = Second, MS = Millisecond.
When I use dexplore or querybuilder MATLAB doesn't seem to process the fact there is a time field here, instead just returning a [ ]. I think this may be something to do with the format of the time field.
My current code looks like this:
%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'structure');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
%Make connection to database. Note that the password has been omitted.
%Using ODBC driver.
conn = database('DATABASE', '', '');
%Read data from database.
curs = exec(conn, ['SELECT ARDAT.Date'...
' , ARDAT.Time'...
' FROM DATABASE.dbo.ARDAT ']);
curs = fetch(curs);
close(curs);
%Assign data to output variable
data = curs.Data;
%Close database connection.
close(conn);
%Clear variables
clear curs conn
Is there a particular way I can force MATLAB to read the Time field as a string instead? Then I can just post process the data to fix it.

Answers (0)

Community Treasure Hunt

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

Start Hunting!