Convert SQL dates to MATLAB datenums
Mostra commenti meno recenti
I'm new to the database toolbox and cannot figure out how to convert SQL dates to MATLAB datenums. In the past, I've been able to do the following for converting Excel dates to MATLAB datenums:
[~, ~, raw, dateNums] = xlsread('path','Metrics','','',@convertSpreadsheetDates);
R = ~cellfun(@isequalwithequalnans,dateNums,raw) & cellfun('isclass',raw,'char');
raw(R) = dateNums(R);
I've tried doing something similar after connecting to a database and running a SQL script but got an error (below). Now that the variable raw is cell array containing my results. Only one column is a date column (the rest are numeric or binary). The variable R does indeed output what I'd expect (1 for date, 0 for number). But the function call to datenum results in an error pasted below the code.
R = cellfun('isclass', raw, 'char');
raw(R) = datenum(R, 'yyyy-mm-dd');
data = cell2mat(raw);
Error using datenum (line 178) DATENUM failed.
Error in DatabaseImport (line 23) raw® = datenum(R, 'yyyy-mm-dd');
Caused by: Error using datenum (line 106) The input to DATENUM was not an array of strings.
Does anyone know an easy way to convert SQL dates to MATLAB dates?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!