How to extract year and month from attached string.

9 次查看(过去 30 天)
I want to extract year and month from attached string data. Please help me.
Thank you so much in advance.
Regard's
Varunesh

采纳的回答

madhan ravi
madhan ravi 2019-1-10
编辑:madhan ravi 2019-1-10
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 个评论
varunesh
varunesh 2019-1-10
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.
madhan ravi
madhan ravi 2019-1-10
Anytime :) , not sure if I can help with that though sorry.

请先登录,再进行评论。

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by