How do I add date and time to my exel filename

4 次查看(过去 30 天)
filename = strcat('Solution_',date,'.xlsx'); sheet = 1; xlRange = 'A3'; xlswrite(filename,transpose(P),sheet,xlRange) xlRange = 'B2'; xlswrite(filename,T,sheet,xlRange) xlRange = 'B3'; xlswrite(filename,n_max_Methanol,sheet,xlRange)
It is working like this with an Date but i can t get it to work with date and ime in the Title, when I suplement date with datetime it says : "Comparison is not defined between datetime and double arrays."

回答(1 个)

Alexandra Harkai
Alexandra Harkai 2016-10-25
This produces an 'ugly' filename but it gets through the datetime->char conversion:
filename = strcat('Solution_',datestr(datetime),'.xlsx')
You can specify a format using underscore instead of the space, for example:
filename = strcat('Solution_',datestr(datetime,'dd-mmm-yyyy_HH:MM:SS'),'.xlsx')

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by