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!