Conversion and Merger of date and time using datetime
Show older comments
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

Accepted Answer
More Answers (1)
dpb
on 26 Jul 2021
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.
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!