Reformat and Merge Date and Time columns
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Douglas Leaffer
el 11 de Sept. de 2023
Comentada: Stephen23
el 2 de Nov. de 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 comentario
Respuesta aceptada
Star Strider
el 12 de Sept. de 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 comentarios
Más respuestas (1)
William Rose
el 11 de Sept. de 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!
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!