MATLAB: Datetime ‘InputFormat’ syntax

datetime

I am looking to convert a cell array of dates to a datetime array. From the text file BUContactOutput.txt I need the Start Time and Stop time in separate datetime arrays. This section of code shows how I am going about creating the StartTime datetime array.
ContactData = readtable('BUContactOutput.txt',...
'Delimiter', ' ', 'HeaderLines',4);
NumOfContacts = height(ContactData);
StartTime = cell(NumOfContacts,1);
for i = 1:NumOfContacts
day = num2str(ContactData.Var1(i));
month = char(ContactData.Var2(i));
year = num2str(ContactData.Var3(i));
time = char(ContactData.Var4(i));
StartTime{i,1} = strcat(year,'-',month,'-',day,'-',time);
end
datetime(StartContact, 'InputFormat', 'yyyy-MMM-dd-HH:mm:SSS')
This method is successful when the time component of StartTime is not included (no ,'-',time in the strcat function and no -HH:mm:SSS in datetime function), yet is not successful when the time component is included. I believe I have a syntax error in my 'InputFormat' content. I am unsure how to resolve the issue and the documentation has yet to provide me with a solution.
https://www.mathworks.com/help/matlab/ref/datetime.html#
Thanks ahead to anyone who offers help.
-Emil

Best Answer

Without seeing the actual format of time, it's difficult to know what the correct format should be. However, it's unusual to have SSS without a ss preceding it. So, possibly:
datetime(StartContact, 'InputFormat', 'yyyy-MMM-dd-HH:mm:ss.SSS')
See my comments to your question if that doesn't solve it.
Note: loop unneeded:
startTime = compose('%d-%s-%d-%s', ContactData.Var1, ContactData.Var2, ContactData.Var3, ContactData.Var4);