Converting hourly data to per shift data

1 view (last 30 days)
Viktor Mirchev
Viktor Mirchev on 28 Sep 2020
Commented: Viktor Mirchev on 28 Sep 2020
Hello,
I would highly appreciate help with the following example.
I have houtly data and I need to convert it to per shift data, where I have 4 shifts that start and end at specific hour:
Shift Start End
A 00:00 07:00
B 07:00 14:00
C 14:00 17:00
D 17:00 00:00
I would like to create a new table where I will see: Date / Shift / Value for the shift*
* the value for each shift is a sum of the respective hours which are included in each shift.
Attached you can find xlsx with sample data.
Thank you for your time!
  2 Comments
Sudhakar Shinde
Sudhakar Shinde on 28 Sep 2020
%You could try:
data = readtable('Hourly2Shift.xlsx');
infmt = 'yyyy-MM - dd''T''HH:mm:ss.S'
%Shift A
starttime = datetime('2020-08 - 1T00:00:00.00', 'InputFormat', infmt);
endtime = datetime('2020-08 - 1T07:00:00.00', 'InputFormat', infmt)
selected = data(isbetween(data.Date, starttime, endtime), :)
Viktor Mirchev
Viktor Mirchev on 28 Sep 2020
Hello, Sudhakar,
Thank you very much for the answer.
I tryed what you suggested, unfortunately I get the following error message:
Error using datetime/isbetween (line 43)
Unable to convert text array to a datetime array because the format was not recognized.
Any suggestion how to resolve it?
Thank you!

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!