Conversion and Merger of date and time using datetime
이전 댓글 표시
The data have two different colum, date and time. Date is in date format and time is in string format. I want to create an another column including both date and time together.

The code I tried below: Although I managed to do that but can't able to see the milliseconds
Data = parquetread('P3007768_2020-11-01-23-59-00.parquet');
fun = @(s)[repmat('0',1,3-numel(s)),s];
Data.h_m_s_ms = regexprep(Data.h_m_s_ms,'\d+$','${fun($&)}');
Data.Date = datetime(Data.h_m_s_ms, "InputFormat","HH:mm:ss:SSS","Format","HH:mm:ss.SSS");
Data.Date = Data.yyyy_mm_dd + timeofday(Data.Date);
Data.Date = datetime(Data.Date ,"InputFormat", "dd-MM-yyyy HH:mm:ss.SSS");
Thanks in advance!
Maitreyee
Results look like the below

채택된 답변
추가 답변 (1개)
dpb
2021년 7월 26일
Didn't do you any favors in using the ":" for the separator of the msec field, did they? :)
But, the above looks like should work -- but you don't show or give us the resulting table.
How about attaching a small section of the above original table as a .mat file? Say something like
tTmp=[head(Data);tail(Data)];
save Data tTmp
Hopefully that will have a set of fields at the bottom that don't have the single-digit s field so have both types of the input format field to deal with.
I don't see what the table wouldn't be showing the .Date field above with the desired format unless something went wrong above and you had an error you didn't mention.
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
