Datenum incoherent documentation

>> datenum('13/03/2011',24)
ans =
6819
>> datenum('12/03/2011',24)
ans =
734840
datenum('13/03/2011','dd/mm/yyyy') % correct!!
Vista32 R2011a

 채택된 답변

Jan
Jan 2011년 5월 14일

1 개 추천

댓글 수: 1

Oleg Komarov
Oleg Komarov 2011년 5월 14일
Thanks, this answers completely my question.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 14일

1 개 추천

That is the format for specifying a pivot year to datenum. Pivot years are only used when the year is decoded as two digits -- which happens in this case because 13 is recognized as not being a valid month number. You can see that the first field is being interpreted as a month number by default by using datestr(734840) which returns 03-Dec-2011

댓글 수: 3

Oleg Komarov
Oleg Komarov 2011년 5월 14일
http://www.mathworks.com/help/techdoc/ref/datenum.html
Expected behaviour:
DateNumber = datenum(DateString, FieldSpecIn)
But then, for bacward compatibility:
DateNumber = datenum(DateString, PivotYear)
Which one should predominate?
Walter Roberson
Walter Roberson 2011년 5월 14일
The documentation of the two argument format says "format string FieldSpecIn" implying a string must be used. The three-argument format says "format FieldSpecIn" which does not inherently restrict to strings.
The documentation could use improvement ;-(
Oleg Komarov
Oleg Komarov 2011년 5월 14일
Arrrrrr...

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

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

질문:

2011년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by