How to extract Jan and feb dates from an array of date strings?
Afficher commentaires plus anciens
Hi,
I have an array of cells of date string. I need to extract all the dates in Jan and Feb. How to do that? Thanks a lot!
Réponse acceptée
Plus de réponses (1)
Peter Perkins
le 3 Août 2018
If possible, don't do this with text. Convert to datetimes:
>> d = datetime(2018,randi(6,10,1),1)
d =
10×1 datetime array
01-Jan-2018
01-Mar-2018
01-Jan-2018
01-Mar-2018
01-Jan-2018
01-May-2018
01-Mar-2018
01-Jan-2018
01-Feb-2018
01-Mar-2018
>> d(d.Month==1 | d.Month==2)
ans =
5×1 datetime array
01-Jan-2018
01-Jan-2018
01-Jan-2018
01-Jan-2018
01-Feb-2018
1 commentaire
JFz
le 3 Août 2018
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!