correct NaT in time series - datetime function

6 ビュー (過去 30 日間)
Martina Raffellini
Martina Raffellini 2018 年 2 月 5 日
回答済み: Walter Roberson 2018 年 2 月 5 日
Hello! I am using the datetime function for a rainfall time series imported from excel:
[a z] = xlsread('complete_series.xlsx',2,'D1:E135714');
t1 = datetime(z(:,1),'InputFormat','dd.MM.yyyy HH:mm:ss');
but each time at midnight i get NaT value.
For example in excel i have 08.09.2015 00:00:00, the datetime function returns NaT. All other values different from midnight are correct.
Where could my mistake be? Thank you

採用された回答

Walter Roberson
Walter Roberson 2018 年 2 月 5 日
See https://www.mathworks.com/matlabcentral/answers/380537-date-format-changes-at-midnight#comment_531541 -- Excel is using a different date format for midnight exactly.
I would suggest, however, that you instead use readtable. You might need to use detectImportOptions first to fix up the format for the time objects, possibly.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by