convert excel time to time in a matlab
19 views (last 30 days)
Show older comments
In excel file (.csv) column A is in format of (12:37:48.123 AM) and I want to have it in MatLab as 12:37:48.123
I tried using the following code:
UTCtime = datetime(dat(8:lastindex), 'Format', 'hh:mm:ss:SSS a')
But got this error:
Error using datetime (line 597)
Numeric input data must be a matrix with three or six columns, or else three, six, or seven separate numeric arrays. You can also create datetimes
from a single numeric array using the 'ConvertFrom' parameter.
Error in Event_129_BATS02 (line 91)
UTCtime = datetime(dat(8:lastindex), 'Format', 'hh:mm:ss:SSS a')
Please help.
0 Comments
Accepted Answer
Campion Loong
on 18 Nov 2022
Simply use 'InputFormat' to parse the excel timestamp, and 'Format' to display it in your format of choice
% Made up data - you can parse an array in one call
excel_timestamp = ["12:37:48.123 AM"; "1:34:42.153 AM"; "3:25:31.635 AM"];
% Use the "InputFormat" & "Format" Name/Value pairs right at construction
datetime(excel_timestamp,"InputFormat","hh:mm:ss.SSS a", "Format", "hh:mm:ss.SSS")
0 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time 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!