Borrar filtros
Borrar filtros

How to convert datetime into a number?

58 visualizaciones (últimos 30 días)
Lu Da Silva
Lu Da Silva el 3 de Abr. de 2022
Comentada: Siddharth Bhutiya el 5 de Abr. de 2022
I have a table whose first column is a timestamp in the format 08-Jan-2016 05:40:00. How do I convert it into numbers?
Wanted output: 20160108054000.
I know the function yyyymmdd(X) is useful but I also need the time to be added.
Thanks!

Respuestas (1)

KSSV
KSSV el 3 de Abr. de 2022
dt = datestr(now,'yyyymmddHHMMSS')
dt = '20220403132156'
  4 comentarios
Lu Da Silva
Lu Da Silva el 3 de Abr. de 2022
what do you mean by class? Where do I check that?
The format is e.g. 08-Jan-2016 05:40:00.
Siddharth Bhutiya
Siddharth Bhutiya el 5 de Abr. de 2022
Avoid using older legacy functions like datestr and datenum. Use the more modern types like datetime to work with timestamped data.
@Lu Da Silva Could you share a code example to demonstrate what you are seeing. This way people can run that on their MATLAB and suggest possible solutions instead of trying to guess what the problem could be.

Iniciar sesión para comentar.

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