I have a txt file with dates in the following form:
200309302300
200309302310
200309302320
......etc
How can I convert these strings into date form?
something like : 2003-Sep-30 23:00 or 2003-09-30 23:00

 채택된 답변

Star Strider
Star Strider 2019년 8월 14일

0 개 추천

I am not certain if the numbers are themselves strings, or numbers.
If they are numbers, this works:
numdate = [200309302300
200309302310
200309302320];
dn = datenum(num2str(numdate), 'yyyymmddHHMM') % Date Numbers
dv = datevec(dn)
dt = datetime(num2str(numdate), 'InputFormat','yyyyMMddHHmm') % ‘datetime’ Array
If they are strings, omit the str2num calls and just insert them directly.

댓글 수: 2

ARGY B
ARGY B 2019년 8월 15일
Thank you :)
Star Strider
Star Strider 2019년 8월 15일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

질문:

2019년 8월 14일

댓글:

2019년 8월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by