converting a date column with yyyymmdd to matlab date number?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Danielle Leblance
am 6 Mai 2018
Beantwortet: Peter Perkins
am 14 Mai 2018
Hi ,
I have a double(not a string)column where each observation is a number with the following format yyyymmdd.How can I convert this column to a column of matlab date numbers. for example, how can I convert 19960530 to 729175
0 Kommentare
Akzeptierte Antwort
Star Strider
am 6 Mai 2018
This seems to work:
ymdCol = [19960530; 19960531; 19960601; 19960602] % Create Column
DN = datenum(num2str(ymdCol), 'yyyymmdd')
ymdCol =
19960530
19960531
19960601
19960602
DN =
729175
729176
729177
729178
0 Kommentare
Weitere Antworten (1)
Peter Perkins
am 14 Mai 2018
Danielle, you may have your reasons for wanting a datenum, but I'd suggest using datetime, for which there's an easy conversion:
>> datetime([19960530;19960531],'ConvertFrom','yyyymmdd')
ans =
2×1 datetime array
30-May-1996 00:00:00
31-May-1996 00:00:00
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!