How to load an Excel file that changes with the date?
3 views (last 30 days)
Show older comments
Sophia Collinson
on 30 Sep 2019
Commented: Sophia Collinson
on 1 Oct 2019
I've created a script that loads and creates a graph from the reliability of the computers within a department. The excel file that contains the data is created new each morning with the date that it is loading for. The date that comes up is in the format such as 30_9_2019, I have requested for it to be changed to a dd_mm_yyyy format, as when trying the
>> date = today('datetime')
date =
datetime
30-Sep-2019
>> formatOut = 'dd_mm_yyyy'
formatOut =
'dd_mm_yyyy'
>> datestr(now,formatOut)
ans =
'30_09_2019'
The whole title for the file is currently d_m_yyyy_04_01_AMReliability.csv with the day and month varying between dd and mm depending on the date, of course.
One issue I find is that when you trt and get Matlab to run from dd_m_yyyy it comes up with a letter for the month.
Is there any way I can get matlab to find the new name automatically as otherwise the date has to be changed and run manually every morning.
0 Comments
Accepted Answer
meghannmarie
on 30 Sep 2019
You could just convert numbers to string and piece it together like this:
date = datetime('now');
[y,m,d] = ymd(date);
filename = [num2str(d) '_' num2str(m) '_' num2str(y) '_04_01_AMReliability.csv ']
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB 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!