Effacer les filtres
Effacer les filtres

Reformatting Dates

5 vues (au cours des 30 derniers jours)
Syed Abbas
Syed Abbas le 27 Déc 2011
Hi, I have dates in the format 12/01/2011. Is there a way to reformat these dates by removing the forward slashes? For example, I want 12/01/2011 to become 12012011. Thanks.

Réponse acceptée

Jan
Jan le 27 Déc 2011
strrep is faster than regexprep:
a = '12/01/2011';
% Or a cell string also:
% a = {'12/01/2011', '12/01/2012'};
b = strrep(a, '/', '');
  1 commentaire
Syed Abbas
Syed Abbas le 27 Déc 2011
thanks!

Connectez-vous pour commenter.

Plus de réponses (1)

Friedrich
Friedrich le 27 Déc 2011
Hi,
you can use regexprep for that:
>> a = '12/01/2011'
a =
12/01/2011
>> regexprep(a,'/','')
ans =
12012011
  1 commentaire
Syed Abbas
Syed Abbas le 27 Déc 2011
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Seismology 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