MATLAB Answers

0

How convert date and time to number that excel will recognize the really date and time?

Asked by Kelly Kyriakou on 23 Sep 2016
Latest activity Commented on by George
on 23 Sep 2016
I need to convert a column that contains dates to numbers and a column that contains time to number also in order to be able to perform some processes. I tried x2mdate and datenum but when I open the file with excel and I convert it again to date and time respectively the excel doesn't recognize the real dates and times. What is my wrong?
Thank you in advance

  1 Comment

Kelly, I don't think you've provided enough information to answer your question. What exactly are your dates and times stored as, you writing to a file or working within MATLAB, and so on.

Sign in to comment.

1 Answer

Answer by George
on 23 Sep 2016

A = table(datetime());
writetable(A, 'myfile.xlsx');

  3 Comments

I can use this function provided thath date and time is one string. In my case thesen are seperate strings and the functions gives me error that cannot recognize the of the date/time strings.
If the dates and times are in two cell arrays, then you can use
strjoin(dates_cell(:), {' '}, times_cell(:))
In addition to Walter's comment you can look at the datetime format properties.

Sign in to comment.