Effacer les filtres
Effacer les filtres

11:49:02:22 DateTime issues

3 vues (au cours des 30 derniers jours)
Jenn
Jenn le 16 Nov 2017
Commenté : the cyclist le 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

Réponse acceptée

the cyclist
the cyclist le 16 Nov 2017
Modifié(e) : the cyclist le 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 commentaires
Jenn
Jenn le 16 Nov 2017
Modifié(e) : Jenn le 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 le 16 Nov 2017
Yeah, I tried that too. :-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by