yyyymmdd to mm-dd-yyyy

6 visualizaciones (últimos 30 días)
Nicole Palermo
Nicole Palermo el 8 de Nov. de 2017
Comentada: Akira Agata el 1 de Abr. de 2019
I unzipped NOAA summary of the day data in matlab and imported it as a table and as a matrix. The datetime is in yyyymmdd (20100801) format. How can I convert it to mm-dd-yyyy(08-01-2010)?
  4 comentarios
Jan
Jan el 1 de Abr. de 2019
@Elias: According to the documentation you need HH, not hh:
t = datetime('2010080123','InputFormat','yyyyMMddHH')
t.Format = 'MM-dd-yyyy';
t
t =
08-01-2010
Akira Agata
Akira Agata el 1 de Abr. de 2019
In addition, how about using datestr function? Like:
t = datetime('2010080123','InputFormat','yyyyMMddHH');
str = datestr(t,'mm-dd-yyyy');
>> str
str =
'08-01-2010'

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Dates and Time 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