How to make a table with date times and durations?
12 次查看(过去 30 天)
显示 更早的评论
Hi, I have a set of datetimes and durations, and I want to merge them and display them in a table. I just can't figure out how to set the timezones, keep on getting errors. Any help is appreciated, I attached the files for extra clarity.
Thanks!
0 个评论
采纳的回答
dpb
2021-7-19
>> t=table(rampD_start,rampD_end,'VariableNames',{'Start','End'});
>> head(t)
ans =
8×2 table
Start End
____________ ____________
May-03 11:37 May-03 11:55
May-05 11:00 May-05 11:07
May-21 12:00 May-21 12:24
May-25 17:23 May-25 17:43
May-26 11:37 May-26 12:00
May-28 11:39 May-28 12:01
May-31 12:18 May-31 12:41
Jun-02 10:20 Jun-02 10:42
>> t.Span=t.End-t.Start;
Cannot combine or compare a datetime array with a time zone with one without a time zone.
>> t.Start.TimeZone
ans =
0×0 empty char array
>> t.End.TimeZone
ans =
'Europe/Amsterdam'
>> t.Start.TimeZone=t.End.TimeZone;
>> t.Span=t.End-t.Start;
>> head(t)
ans =
8×3 table
Start End Span
____________ ____________ ________
May-03 11:37 May-03 11:55 00:18:00
May-05 11:00 May-05 11:07 00:07:00
May-21 12:00 May-21 12:24 00:24:00
May-25 17:23 May-25 17:43 00:20:00
May-26 11:37 May-26 12:00 00:23:00
May-28 11:39 May-28 12:01 00:22:00
May-31 12:18 May-31 12:41 00:23:00
Jun-02 10:20 Jun-02 10:42 00:22:00
>>
Or, of course, you can remove the TimeZone from both if don't want to keep it.
Alternatively, go back to the creation of the data from which the two datetime arrays came and ensure they're imported the same way to avoid the mismatch in the beginning.
0 个评论
更多回答(1 个)
Sameer Pujari
2021-7-19
Table can be found simply using this
T=table(rampD_start,rampD_end,rampD_dur)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!