Borrar filtros
Borrar filtros

converting number to date number

51 visualizaciones (últimos 30 días)
wesso Dadoyan
wesso Dadoyan el 1 de Oct. de 2016
Respondida: Steven Lord el 1 de Oct. de 2016
I have a column of dates that are number (double format) such as 19940127 how can i convert it to matlab numeric date that corresponds to 1994/01/27?

Respuesta aceptada

Star Strider
Star Strider el 1 de Oct. de 2016
Editada: Star Strider el 1 de Oct. de 2016
One approach:
dd = 19940127;
out = datestr(datenum(num2str(dd, '%d'), 'yyyymmdd'), 'yyyy/mm/dd')
out =
1994/01/27
To get the date number, just use part of that:
out_dn = datenum(num2str(dd, '%d'), 'yyyymmdd')
EDIT Added ‘out_dn’.

Más respuestas (1)

Steven Lord
Steven Lord el 1 de Oct. de 2016
Use the datetime function with the 'ConvertFrom', 'yyyymmdd' option.

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by