필터 지우기
필터 지우기

problem with datetime : day is wrong

조회 수: 2 (최근 30일)
piero
piero 2023년 9월 22일
댓글: Walter Roberson 2023년 9월 22일
year=2008
year = 2008
month=2
month = 2
day=31
day = 31
hh =[ year month day ]
hh = 1×3
2008 2 31
datetime(hh) %it's not correct ((correct day is 31 not 2)
ans = datetime
02-Mar-2008
%i try to change datetime default but the result is the same
datetime.setDefaultFormats('defaultdate','yyyy-MM-dd')
datetime(hh)
ans = datetime
2008-03-02

채택된 답변

Angelo Yeo
Angelo Yeo 2023년 9월 22일
There was no Feb 31st in 2008.
  댓글 수: 4
James Tursa
James Tursa 2023년 9월 22일
편집: James Tursa 2023년 9월 22일
+1 @Steven Lord I use this feature a lot. E.g., "What date was the 200th day of the year in 1997?"
datetime(1997,1,200)
ans = datetime
19-Jul-1997
Walter Roberson
Walter Roberson 2023년 9월 22일
It is a common trick to code datetime([year 1 daynumber]) instead of datetime([year 1 1])+days(daynumber-1)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by