How to convert datetime into a number?

조회 수: 121 (최근 30일)
Lu Da Silva
Lu Da Silva 2022년 4월 3일
댓글: Siddharth Bhutiya 2022년 4월 5일
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!

답변 (1개)

KSSV
KSSV 2022년 4월 3일
dt = datestr(now,'yyyymmddHHMMSS')
dt = '20220403132156'
  댓글 수: 4
Lu Da Silva
Lu Da Silva 2022년 4월 3일
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 2022년 4월 5일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by