How to extract year and month from attached string.

I want to extract year and month from attached string data. Please help me.
Thank you so much in advance.
Regard's
Varunesh

 Risposta accettata

madhan ravi
madhan ravi il 10 Gen 2019
Modificato: madhan ravi il 10 Gen 2019
load('date.mat');
a=date{:,:};
b=regexp(a,'\T','split');
b=[b{:}];
B=datetime(b(1:2:end).','InputFormat','yyyy-MM-dd');
[year,month,day]=ymd(B);

3 Commenti

If you want them to display it as table finally after splitting then:
Result=[year month day];
T=array2table(Result);
T.Properties.VariableNames={'Year','Month','Day'};
Thank you so much. It is working.
Can you help me with another question? Please look once, If possible then please help me. a link is below.
Anytime :) , not sure if I can help with that though sorry.

Accedi per commentare.

Più risposte (1)

times = datetime(date.datetime, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ss');
By the way, your times are not completely sorted.

Categorie

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by