date and time formatting

Hi everyone, i have a csv file which contains date and time cells to be imported and represented in different format in matlab graphs when i convert date and time in matlab it doesnt show the correct date and time although ive used different methods to do that.
  • This is one example of date and time format in csv itself (44138.4243609954), this is with general format of cell in excel.
  • When i import to matlab it shows this value (44138.4243609954) when i check it in cell
  • this is the value that it should show in graph axis after right conversion (2020-11-03 10:11:05.000), note: the time in 24h system.
  • the value of date and time that it show instead is (0120-11-04 10:11:79).
Thanks in advance.

3 个评论

It isn't clear to me what the edit was you made, so I don't see how my answer doesn't apply.
I've added the 4th point to clarify it more. There might be some error in time reference, I'm not sure exactly if I have to calibrate in someway but I have no idea. Btw I've checked the link you've posted last comment but it didn't help unfortunately. Thanks anyway.
datetime(44138.4243609954,'ConvertFrom','Excel')
ans = datetime
03-Nov-2020 10:11:04
I don't see why my answer wouldn't work for you, as you can see it works in R2020b. If you have trouble applying this to your data, you will have to post your data and the code you tried. If you're not using R2020b you should clarify that as well.

请先登录,再进行评论。

回答(1 个)

Rik
Rik 2020-11-5

0 个投票

See the datetime documentation for how to convert Excel dates to a datetime object that you can use in other functions. See the datetick function for how to set your tick labels to a specific date format.

类别

帮助中心File Exchange 中查找有关 Dates and Time 的更多信息

标签

评论:

Rik
2020-11-5

Community Treasure Hunt

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

Start Hunting!

Translated by