changing the format of a date vector

1 回表示 (過去 30 日間)
Sabbas
Sabbas 2012 年 8 月 1 日
Dear all,
I have the vector
A={
19/04/09'
'17/05/09'
'14/06/09'
'12/7/2009'
'9/8/2009'
'6/9/2009'
'4/10/2009'
'1/11/2009'
'29/11/09'
'27/12/09'
'31/01/10'
'28/02/10'
'28/03/10'
'25/04/10'
'23/05/10'
'20/06/10'
'18/07/10'
'15/08/10'
'12/9/2010'
'10/10/2010'
'7/11/2010'
'5/12/2010'
'2/1/2011'
'30/01/11'
'27/02/11'
'27/03/11'
'24/04/11'
'22/05/11'
'19/06/11'
'17/07/11'
'14/08/11'
'11/9/2011'
'9/10/2011'}
I want to have only the format dd/mm/yy. So instead of having '9/10/2011' i want to have '9/10/11'
thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 1 日
編集済み: Azzi Abdelmalek 2012 年 8 月 2 日
B=cellstr(datestr(datenum(A,'dd/mm/yyyy'),'dd/mm/yy'))

その他の回答 (2 件)

Oleg Komarov
Oleg Komarov 2012 年 8 月 1 日
idx = cellfun('size',A,2) > 8;
A(idx) = cellstr(datestr(datenum(A(idx),'dd/mm/yyyy'),'dd/mm/yy'))
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 2 日
this does'nt work for 1/4/2009

サインインしてコメントする。


Walter Roberson
Walter Roberson 2012 年 8 月 1 日
idx = cellfun('size',A,2) > 8;
A(idx) = cellfun( @(S) S([1:end-4 end-1:end]), A(idx), 'Uniform', 0);

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by