datestr generating different string

조회 수: 1 (최근 30일)
Simon Lind
Simon Lind 2021년 5월 1일
댓글: Simon Lind 2021년 5월 1일
I have an array with days, months and years. This is my string
[myd '/' mym '/' myy]
ans =
20/01/2014
But datestr generates this
datestr([myd '/' mym '/' myy])
ans =
06-Jul-0025
Any clue?
Thanks

채택된 답변

Chad Greene
Chad Greene 2021년 5월 1일
How about
myy = 2014;
mym = 1;
myd = 20;
datestr(datenum(myy,mym,myd),'dd/mm/yyyy')
ans = '20/01/2014'
  댓글 수: 3
Chad Greene
Chad Greene 2021년 5월 1일
How's this?
datestr(datenum(string([myd '/' mym '/' myy]),'dd/mm/yyyy'))
Simon Lind
Simon Lind 2021년 5월 1일
I just removed the 'string' and now it works
datestr(datenum(([myd '/' mym '/' myy]),'dd/mm/yyyy'))
thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by