Reformat and Merge Date and Time columns
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Douglas Leaffer
il 11 Set 2023
Commentato: Stephen23
il 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 Commento
Risposta accettata
Star Strider
il 12 Set 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 Commenti
Più risposte (1)
William Rose
il 11 Set 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!
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!