weekday function odd results

1 回表示 (過去 30 日間)
James Grayot
James Grayot 2017 年 2 月 21 日
回答済み: Steven Lord 2017 年 2 月 21 日
I am using the function weekday and I find that, for instance, on 19790531 and 19790601 are both Wednesdays according to the function. Not only is 19790531 a Thursday, two subsquent dates should not be assigned to the same weekday.
Can anyone shed some light on this?
ps:
I am simply doing:
[DayNumber,DayName] = weekday(19790531)

採用された回答

Steven Lord
Steven Lord 2017 年 2 月 21 日
That doesn't do what you think it does.
>> datestr(19790531)
ans =
18-Aug-4184
If you intended for that number to refer to May 31, 1979:
>> D = datetime(19790531, 'ConvertFrom', 'yyyymmdd')
D =
datetime
31-May-1979 00:00:00
>> [DayNumber, DayName] = weekday(D)
DayNumber =
5
DayName =
Thu

その他の回答 (0 件)

カテゴリ

Help Center および 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