Let's make a sample timetable.
MeasurementTime = datetime({'2015-12-18 08:03:05'; ...
'2015-12-18 10:03:17';...
'2015-12-18 12:03:13'}, ...
'Format', "yyyy-MM-dd 'at' hh:mm:ss");
Temp = [37.3;39.1;42.3];
Pressure = [30.1;30.03;29.9];
WindSpeed = [13.4;6.5;7.3];
WindDirection = categorical({'NW';'N';'NW'});
TT = timetable(MeasurementTime,Temp,Pressure,WindSpeed,WindDirection);
Write it to a file.
writetimetable(TT, fullfile(tempdir, 'mydata.txt'))
Now try to import the datetime variable from that file.
- Open the file in the Import Tool.
- Change the delimiter to "comma" and the MeasurementTime variable should contain just the representation of the date and time.
- Click the dropdown showing "text" below the MeasurementTime identifier.
- Click on the "more date formats" and scroll to the bottom of the list where you can enter a custom format.
- Enter the option I specified as the Format when I created the datetime MeasurementTime above (without the double quotes but with the single quotes.) This uses the capability to "escape" literal character [a-zA-Z] in a format that is described in the description of the Format property on the documentation page for datetime.
- Import that variable and you should see it contains the appropriate date and time with the word 'at' between the date and time.
Best Answer