How to remove the H:M:S in datetime variables when "writetable" to Excel

10 views (last 30 days)
Hi! I find a problem in my datetime variables when writing my table results into Excel via "writetable".
  • I would like to keep the D/M/Y format (e.g. 15/03/2008) in the table, but I finally find that the Excel file shows the D/M/Y H:M:S format (e.g. 15/03/2008 12:00:00 AM).
I am wondering how can I fix this problem --- so that the Excel file can show the original datetime format (without H:M:S) as in MATLAB.
Thanks a lot for your help!

Accepted Answer

Vinesh Katewa
Vinesh Katewa on 12 Jul 2021
Hi Jiashun Wu,
I understand that you want the output in D/M/Y format and not with the H:M:S which is the default output of the function. To get the output of datetime function in a specific format, you can use the 'Format' name value pair with datetime function as follows:
>> T = datetime();
>> D = datetime(T, 'Format', 'dd/MM/yyyy');
Hope this helps.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by