필터 지우기
필터 지우기

converting number to date number

조회 수: 51 (최근 30일)
wesso Dadoyan
wesso Dadoyan 2016년 10월 1일
답변: Steven Lord 2016년 10월 1일
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?

채택된 답변

Star Strider
Star Strider 2016년 10월 1일
편집: Star Strider 2016년 10월 1일
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’.

추가 답변 (1개)

Steven Lord
Steven Lord 2016년 10월 1일
Use the datetime function with the 'ConvertFrom', 'yyyymmdd' option.

카테고리

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