Reformat and Merge Date and Time columns
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2023-9-12
For what it’s worth —
LD = load('RVdata.mat');
data = LD.data
data.Date = data.Date + timeofday(data.TimeHHmmss);
data = removevars(data,2)
.
3 个评论
更多回答(1 个)
William Rose
2023-9-11
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!
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!