Find min and max datetime in table
51 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Frederick Awuah-Gyasi
am 19 Mai 2022
Kommentiert: Voss
am 19 Mai 2022
table
A , Datetime,
2 05/20/22
2 05/20/23
3 04/12/99
3 06/12/02
the goal is to have two more columns with min and max dates
table
A , Datetime, Min, Max
2 05/2/22 05/2/22 05/2/23
2 05/2/23 05/2/22 05/2/23
3 04/12/01 04/12/01 06/12/02
3 06/12/02 04/12/01 06/12/02
I was tring table_min = groupsummary (table,{table.A,table.Datetime}, 'min'}
table_max= groupsummary (table,{table.A,table.Datetime}, 'max'}
So I join this date to table but i'm getting an error :
[groupingData,groupVars] = matlab.internal.math.parseGroupVars(groupVars,tableFlag,'groupsummary',T);
Thank you.
0 Kommentare
Akzeptierte Antwort
Voss
am 19 Mai 2022
T = table( ...
[2;2;3;3], ...
datetime({'05/20/22';'05/20/23';'04/12/99';'06/12/02'},'InputFormat','MM/dd/yy'), ...
'VariableNames',{'A' 'Datetime'})
table_min = groupsummary (T, 'A', 'min')
table_max = groupsummary (T, 'A', 'max')
g = findgroups(T.A)
T.Min = table_min{g,'min_Datetime'};
T.Max = table_max{g,'max_Datetime'};
T
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!