calculate the difference of hours / minutes of specific day

Posted 1 month ago by gutogirardon

I have the following return:

2018-10-18 02:22:35 O
2018-10-18 02:22:34 OI
2018-10-18 02:22:32 II
2018-10-18 02:22:31 I

Where the first value is a timestamp and the second a type field.

This type field is used to determine the date entry of the value.

I = Input;
II = Interval;
OI = Interval Return;
O = Output;

I want to calculate the time difference of I with O, decreasing with the difference of II and OI.

My biggest problem is being in how to compare the type (knowing which one is the first and the last one) and also how not to mix the days because there are more results.

The goal is to create a table containing day, start time, end time and this time difference for each day.

I accept any suggestion.

I'm grateful.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.