Reformat and Merge Date and Time columns
3 views (last 30 days)
Show older comments
Douglas Leaffer
on 11 Sep 2023
Commented: Stephen23
on 2 Nov 2023
Hello. Could use some help merging the Date and Time columns in the attached data file. Date (Column 1) is a DateTime vector dd-MMM-yyyy and Time is a vector that contains 31-Dec-1899 HH:mm:ss What I need is to delete the 31-Dec-1899 default year and merge the true Date (02-Sep-2016) with the remaining Time from column 2. I have tried the following to no avail.
load RVdata.mat
tim = datetime(RVdata.TimeHHmmss, 'InputFormat','dd-MMM-yyyy HH:mm:ss', 'Format','HH:mm:ss')
1 Comment
Accepted Answer
Star Strider
on 12 Sep 2023
For what it’s worth —
LD = load('RVdata.mat');
data = LD.data
data.Date = data.Date + timeofday(data.TimeHHmmss);
data = removevars(data,2)
.
3 Comments
More Answers (1)
William Rose
on 11 Sep 2023
load('RVdata');
dt1=data.(1)+(3600*hour(data.(2))+60*minute(data.(2))+second(data.(2)))/86400;
dt1.Format='yyyy-MMM-dd hh:mm:ss';
dt1(1:4)
Try it. Good luck!
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!