How to convert excel date and time data into numerical integer matrix [year, month, day, hour, minute, second]
Ältere Kommentare anzeigen
Greetings,
I have huge excel data starts with the following columns:

Sample data file attached.
I want to sort the data by comparing months/years/hours inside functions. Hence, I need the years, months, days, hours to be seperate integers.
needed output:
year = 2016
month = 11
day = 23
hour = 16
minute = 33
How can I do that (knowing I have tried reading file as table and time table and many other functions).
I would apreciate any help.
2 Kommentare
Stephen23
am 21 Nov. 2022
@Anwaar Alghamdi: please upload a sample file by clicking the paperclip button. This does not have to be your complete data file or contain your confidential data, but it does need to exactly represent the format of your actual data files.
Anwaar Alghamdi
am 21 Nov. 2022
Akzeptierte Antwort
Weitere Antworten (1)
cr
am 21 Nov. 2022
0 Stimmen
An easier way of doing that would be convert the dates into datenum so that you dont have to individually compare years,months,...sec,millisec. date_number = datenum(datescolumn);
Unless you are using older versions of Matlab, a column with dates is automatically imported as datenumbers. If it doesn't datenum() may be used.
2 Kommentare
Anwaar Alghamdi
am 21 Nov. 2022
cr
am 21 Nov. 2022
Well, then you may create your own date number for dates based on years, days and hours. To seggregate the dates into these use datavec(). E.g.
ymd = datevec(datesColumn);
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!