How can I format the datetime when the format is not recognized?

5 ビュー (過去 30 日間)
Jade O'Brien-Smith
Jade O'Brien-Smith 2020 年 3 月 20 日
コメント済み: Sanduni 2022 年 11 月 8 日
Hello, I'm having some trouble setting my datetime format. The original timestamps I get looks like this "0200310T102613000" and I've tried to format it like this;
p1 = readtable('10.csv');
date1 = table2cell(p1(:,1));
dateT = datetime(date1,'InputFormat','YYYYmmdd''T''HHmmssSSS');
I've even tried removing the date secion (i.e. "102613000") and running is like this;
dateT = datetime(date1,'InputFormat','HHmmssSSS');
However I always get an error using the datetime function. Does anyone have any ideas for me?
Thanks!

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 3 月 20 日
a="20200310T102613000";
>> datetime(a,'inputformat','yyyyMMdd''T''HHmmssSSS')
ans =
datetime
10-Mar-2020 10:26:13
  2 件のコメント
Jade O'Brien-Smith
Jade O'Brien-Smith 2020 年 3 月 31 日
Thank you
Sanduni
Sanduni 2022 年 11 月 8 日
Thank you so much

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by