Bit difficult to describe but to do with date/times from a log.

Reshaw

Board Regular
Joined
Mar 2, 2011
Messages
53
Apologies for the vague title but I'm not sure how best to describe this challenge.

I have a log from our GPS tracking system for all of our company trailers. I am trying to work out how long each trailer stayed on site at a particular destination for.

The first complication is that for each trailer there are several pings (lines in the log) that will have a start date/time and an end date/time. The trailer may or may not have moved in between the pings.

So I have written a function that can detect the first and last rows that pertain to a single trailer that has not moved.
This looks like:-
=IF(OR(C2<>C1, A2<>A1, AND(A2=A1, C2=C1, G1>0.833)), "BEGIN", "") //Cell F2 below
and
=IF(OR(C4<>C3, A4<>A3, AND(A4=A3, C4=C3, G3>0.833)), "END", "") //Cell G2 below

What I need to do now is to calculate the time between the first and arrival date/time and the last departure date/time with a variable number of rows in between. I tried using nested if statements to keep looking one higher but it maxes out at 7 iterations and some are longer than that. I am looking for an automatic way of doing this so that I can speed up a process of creating this invoice each week.

On the table below, I need to calculate the difference between B2 and c3, then b4 and c7, b8 and c9, b10 and c10. Please note there may be only one row.

I anticipate a function that checks to see if column G# = "END" then looks for the previous Begin and looks up the arrival and departure dates/times. But I am struggling to find a way to do this without the if statement.

Any suggestions are appreciated.
Thanks
Rob


Sample Data below>>

VehicleArrivalDepartureDurationtime between ShiftsStartEnd
APL00101/09/2014 04:4301/09/2014 16:1211:29:0400:03:51BEGIN
APL00101/09/2014 16:1602/09/2014 11:2419:07:33312:02:04END
APL00115/09/2014 11:2615/09/2014 11:2700:01:0300:34:00BEGIN
APL00115/09/2014 12:0117/09/2014 10:431.22:42:2500:00:02
APL00117/09/2014 10:4317/09/2014 16:0305:20:0900:03:51
APL00117/09/2014 16:0717/09/2014 16:5700:49:37END
APL00210/09/2014 06:2711/09/2014 02:4620:19:0100:03:41BEGIN
APL00211/09/2014 02:4911/09/2014 13:1810:28:19283:52:53END
APL00223/09/2014 09:1124/09/2014 07:2622:15:06297:20:53BEGINEND
APL00206/10/2014 16:4707/10/2014 18:2325:35:5800:00:02BEGIN
APL00207/10/2014 18:2308/10/2014 06:5812:35:0200:04:00
APL00208/10/2014 07:0208/10/2014 09:3802:36:2900:11:07
APL00208/10/2014 09:4908/10/2014 09:5200:03:1000:12:51
APL00208/10/2014 10:0508/10/2014 10:5400:48:27END

<tbody>
</tbody>
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,216,081
Messages
6,128,694
Members
449,464
Latest member
againofsoul

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top