Sort excel with respect to column date

1 view (last 30 days)
Nagham Kabbara
Nagham Kabbara on 9 Nov 2015
Answered: Walter Roberson on 9 Nov 2015
hi, in my program the user is able to add data which will be added to an excel sheet, this data contains a date.
what i would like to do is to sort the data in the excel with respect to the column date. i tried importing the array to matlab and use sortrows and i tried running a macro using actxserver but it didn't work!! i don't know if there's something missing here!!!
please help

Answers (1)

Walter Roberson
Walter Roberson on 9 Nov 2015
If you have R2014b or later, you can use readtable() to read the xls file in a way that the dates will appear as datetime objects that can then be sorted.
If not then you can use xlsread(). If the dates are stored in Excel date format then what you receive in MATLAB will be something you can sort(), even though it will not be exactly in MATLAB datenum format. If the dates are stored in strings in Excel then you can use datenum() to convert them to datenum format, which you can then sort.

Tags

Community Treasure Hunt

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

Start Hunting!