Datetime 'convertfrom' forcing dates to be Jan2019
Show older comments
Hi there,
I'm trying to convert my data's date format from MM/dd/yyyy to dd/MM/yyyy.
I'm using;
load conductortemps17sept19_4 %datafile
T = conductortemps17sept194;
T.Properties.VariableNames = {'Datapoint' 'LogDate' 'LogTime' 'Broken' 'Uncoated' 'Solvent' 'Water' 'MV01' 'MV06'};
T(1,:) = []; %Remove headings from data
T.LogDate = datetime(T.LogDate, 'ConvertFrom', 'MM/dd/yyyy', 'Format','dd/MM/yyyy'); %convert to british dates
T.LogDate.Format = 'HH:mm:ss dd/MM/yyyy';
T.LogTime.Format = 'HH:mm:ss dd/MM/yyyy';
T.Time = T.LogDate + timeofday(T.LogTime); %combine date and time
The 'Logdate' data ranges 17th September to 1st October (today). However it's converting all dates to be Jan2019.
This code has been working fine for the past few weeks, giving correct dates. What am I doing wrong?
The attachments are the loaded file and the output I'm seeing for dates.
Kind regards,
Oliver
2 Comments
Stephen23
on 1 Oct 2019
Your uploaded table does not contain the variable/column LogDate, so we have no way to know how your code relates to your uploaded data, if at all (it would throw an error).
Oliver Higbee
on 2 Oct 2019
Accepted Answer
More Answers (0)
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!

