フィルターのクリア

how to convert yymmdd to dd/mm/yyyy

10 ビュー (過去 30 日間)
davit petraasya
davit petraasya 2016 年 6 月 6 日
コメント済み: davit petraasya 2016 年 6 月 6 日
Hi
Does anyone know how to convert yymmdd to dd/mm/yyyy? I have dates is given in the yymmdd format, such as 750525,780215,.....which mean year 1975, month-5, day-25 or year 1978, month-2,day-15. I wanted to convert the date in the form dd/mm/yyyy which is as 25/05/1975, 15/02/1978.
How I can do it?
Thanks a lot!

採用された回答

Jos (10584)
Jos (10584) 2016 年 6 月 6 日
A = {'750525','780215'}
B = cellstr(datestr(datenum(A,'yymmdd'),'dd/mm/yyyy'))
  5 件のコメント
Jos (10584)
Jos (10584) 2016 年 6 月 6 日
A0 = [750525, 780215] A = arrayfun(@(x) sprintf('%06d',x), A0, 'un', 0) % convert to cell array of strings
davit petraasya
davit petraasya 2016 年 6 月 6 日
This is great Jos, it works perfectly. Thank you a lot!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2016 年 6 月 6 日
Use the 'ConvertFrom' option with datetime to create a datetime object representing your date.
x = 19990511;
D = datetime(x, 'ConvertFrom', 'yyyymmdd')
  1 件のコメント
davit petraasya
davit petraasya 2016 年 6 月 6 日
Thanks Steven for your concern.

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

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by