Borrar filtros
Borrar filtros

problem with datetime : day is wrong

2 visualizaciones (últimos 30 días)
piero
piero el 22 de Sept. de 2023
Comentada: Walter Roberson el 22 de Sept. de 2023
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

Respuesta aceptada

Angelo Yeo
Angelo Yeo el 22 de Sept. de 2023
There was no Feb 31st in 2008.
  4 comentarios
James Tursa
James Tursa el 22 de Sept. de 2023
Editada: James Tursa el 22 de Sept. de 2023
+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 el 22 de Sept. de 2023
It is a common trick to code datetime([year 1 daynumber]) instead of datetime([year 1 1])+days(daynumber-1)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by