Azzera filtri
Azzera filtri

11:49:02:22 DateTime issues

3 visualizzazioni (ultimi 30 giorni)
Jenn
Jenn il 16 Nov 2017
Commentato: the cyclist il 16 Nov 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

Risposta accettata

the cyclist
the cyclist il 16 Nov 2017
Modificato: the cyclist il 16 Nov 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 Commenti
Jenn
Jenn il 16 Nov 2017
Modificato: Jenn il 16 Nov 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 il 16 Nov 2017
Yeah, I tried that too. :-)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by