![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1489937/image.png)
problem with datetime : day is wrong
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
piero
am 22 Sep. 2023
Kommentiert: Walter Roberson
am 22 Sep. 2023
year=2008
month=2
day=31
hh =[ year month day ]
datetime(hh) %it's not correct ((correct day is 31 not 2)
%i try to change datetime default but the result is the same
datetime.setDefaultFormats('defaultdate','yyyy-MM-dd')
datetime(hh)
0 Kommentare
Akzeptierte Antwort
Angelo Yeo
am 22 Sep. 2023
There was no Feb 31st in 2008.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1489937/image.png)
4 Kommentare
Walter Roberson
am 22 Sep. 2023
It is a common trick to code datetime([year 1 daynumber]) instead of datetime([year 1 1])+days(daynumber-1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calendar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!