anyway to compare date in Matlab
10 views (last 30 days)
Show older comments
I have two file with the same name, but different location, for example:
file1: D:/test/abc.m
file2: E:/test/abc.m
one of them has been updated. I could check the last modified name by:
filenames1=dir'(D:/test/);
time_file1=filenames(3).date;
filenames2=dir'(E:/test/);
time_file2=filenames(3).date;
the 'time_file1' and 'time_file2' represents the last modified time of these two files, the format is like: '22-Jan-2019 08:43:06'
my question is:
is there anyway to know which is ealier/later, so that I can keep the latest one for use, with out left-click, then property, to look at.
Bests,
Yu
0 Comments
Accepted Answer
Star Strider
on 20 Mar 2019
It might be easier to use the datenum field instead if you simply want to compare dates:
filenames1=dir'(D:/test/);
time_file1=filenames(3).datenum;
filenames2=dir'(E:/test/);
time_file2=filenames(3).datenum;
datediff = time_file1 - time_file2;
4 Comments
More Answers (1)
Pruthvi G
on 20 Mar 2019
[~,Data] = dos('dir D:/test/abc.m');
Scanned_data = textscan(Data,'%s');
Date_modified = Scanned_data{1}{15};
0 Comments
See Also
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!