Borrar filtros
Borrar filtros

11:49:02:22 DateTime issues

3 visualizaciones (últimos 30 días)
Jenn
Jenn el 16 de Nov. de 2017
Comentada: the cyclist el 16 de Nov. de 2017
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

Respuesta aceptada

the cyclist
the cyclist el 16 de Nov. de 2017
Editada: the cyclist el 16 de Nov. de 2017
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 comentarios
Jenn
Jenn el 16 de Nov. de 2017
Editada: Jenn el 16 de Nov. de 2017
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 el 16 de Nov. de 2017
Yeah, I tried that too. :-)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by