I understand that you would like to display dates read from an excel file.
You can try the following:
- In the provided code, it is unclear what the first parameter passed to datetime() i.e. s contains. Ensure that it complies with the valid input arguments for datetime()
- Ensure that the data in the spreadsheet has dates in the correct format. You can use readtable() to get data from the excel sheet. You can refer to the following answer for further details regarding it: https://www.mathworks.com/matlabcentral/answers/577180-how-to-use-datetime-datestr
- Specify the input format in datetime()
- To display the date in the figure, you can pass the value returned by datetime() to datestr() as follows:
t = datetime('now','TimeZone','local','Format','d-MMM-y');
datestr(t,'dd mmm yyyy');
You can use the following documentations as reference: