フィルターのクリア

11:49:02:22 DateTime issues

3 ビュー (過去 30 日間)
Jenn
Jenn 2017 年 11 月 16 日
コメント済み: the cyclist 2017 年 11 月 16 日
I am trying to process several .xls files with the a horrible datetime format and I can not for the life of me figure it out!
20-OCT-2015 11:49:02:22
20-OCT-2015 11:49:03:22
20-OCT-2015 11:49:04:22
20-OCT-2015 11:49:05:22
20-OCT-2015 11:49:06:22
20-OCT-2015 11:49:07:22
The colon between the second and nth second is messing me up. I need to separate hh,mm,ss into separate vectors but I can't seem to manipulate this date. I've tried getting rid of :22 (the 22 eventually changes to another number) by extracting the data I want but all I get is errors. I tried formatting into cell, table, char, double. nothing... I've tried multiple ways of splitting, extracting, substringing.... Here are some of my code attempts... and errors (I've gotten frustrated and already deleted many of them
tTime=substring(ttTime,12,8);
Undefined function 'substring' for input arguments of type 'double'.
another:
Error using strsplit (line 80)
First input must be either a character vector or a string scalar.
The substring gives me the same error for character, table, cell.... Please help me

採用された回答

the cyclist
the cyclist 2017 年 11 月 16 日
編集済み: the cyclist 2017 年 11 月 16 日
Does this help?
ttTime = {'20-OCT-2015 11:49:02:22';
'20-OCT-2015 11:49:03:22'};
dn = datenum(ttTime,'dd-mmm-yyyy HH:MM:SS:FFF')
There are more modern ways of handling dates, but I have not yet fully embraced them. I think the following is correct:
ttTime = {'20-OCT-2015 11:49:02:22' ...
'20-OCT-2015 11:49:03:22'};
dt = datetime(ttTime,'InputFormat','dd-MMM-yyyy hh:mm:ss:SS')
  3 件のコメント
Jenn
Jenn 2017 年 11 月 16 日
編集済み: Jenn 2017 年 11 月 16 日
sigh.... I was almost there.... this is what I was trying to use. I see where I went wrong now.
Time = datestr(ttTime,'dd-mmm-yyyy HH:MM:SS:FF' );
the cyclist
the cyclist 2017 年 11 月 16 日
Yeah, I tried that too. :-)

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by