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 ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by