How do I align date formats
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I have some dates I need converted to the same format. I've boiled it down to the following possible formats but now I'm stuck:
01/01/2016
1/01/2016
01/1/2016
1/1/2016
I need them all to be: 01/01/2016
I've tried a few things but nothing works without messing up something else at this point.
댓글 수: 0
채택된 답변
Walter Roberson
2016년 11월 16일
dates = {'01/01/2016', '1/01/2016', '01/1/2016', '1/1/2016'};
datestr(datenum(dates), 'dd/mm/yyyy')
댓글 수: 0
추가 답변 (1개)
Peter Perkins
2016년 11월 18일
Using datetimes, Walter's suggestion would look like
>> dates = {'01/01/2016'; '1/01/2016'; '01/1/2016'; '1/1/2016'};
>> datetime(dates,'Format','dd/MM/yyyy')
ans =
01/01/2016
01/01/2016
01/01/2016
01/01/2016
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!