No InputFormat 'YYMMDD' found for datetime
조회 수: 3 (최근 30일)
이전 댓글 표시
Is there a way to transform '240331' into '31 March 2024' ?
The following does not work:
datetime('240331',InputFormat,'YYMMDD')
댓글 수: 2
채택된 답변
Steven Lord
2024년 5월 2일
Either leave the quotes off but use == (if you're using a sufficiently recent release) or add quotes. You will need to adjust your format specifier, though.
datetime('240331',InputFormat = 'yyMMdd')
datetime('240331','InputFormat','yyMMdd')
You need to use 'yy' instead of 'YY' and 'dd' instead of 'DD'.
datetime('240331',InputFormat = 'YYMMDD')
댓글 수: 3
Steven Lord
2024년 5월 2일
Since the format needs to have ways to represent both the Month component and the minute component of a datetime, the most natural representation IMO is for M to be case sensitive. [This was not a choice MathWorks made; that's part of the Unicode Locale Data Markup Language specification linked from the documentation page I reference below. I believe the LDML uses the symbols from ISO standard 8601.]
The table in the entry for the Format property on the datetime documentation page lists the character and character sequences that have special meanings when used in a format specifier (either the InputFormat name-value argument to the constructor or the Format property which can be set in the constructor or after the object has been created.)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!