필터 지우기
필터 지우기

11:49:02:22 DateTime issues

조회 수: 1 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by