How to calculate difference between dates while values in rows are equal?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all, I want to find rows where the values in the first column of the matrix are equal (identifying number for stocks) and calculate the difference between the the start date of equal values and the last date of equal values. Then I want to check if the difference between dates are < 20 and if so, I want to delete the part of the matrix between the dates. In the file attached, the first column if the identifying number of the stocks, and the second column are the dates in serial date numbers. Hope anyone can help!
Many thanks in advance!
0 Kommentare
Antworten (1)
vijaya lakshmi
am 26 Feb. 2018
Hi Louisa,
In order to find the difference between 2 dates which are stored in 'serial date number' format
First, convert the "serial date number" format to "date" format
t1=datetime(725617,'ConvertFrom','datenum');
t2=datetime(725618,'ConvertFrom','datenum');
Later find the difference between dates
diff= datenum(t2) - datenum(t1);
Or the other way is, directly find the difference between the dates which are in "serial date number" format
datenum(725620)-datenum(725619)
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!