I have columns of dates and times that fleet vehicles have been taken out of service (OOS), and a second set of columns in which the vehicles have returned back into service (INS). I am trying to build a monthly rollup that calculates the total time that any given vehicle was OOS during each month.
The problem I have is that vehicles are often OOS during timeframes that span multiple months. ARFF-14, as a good example, was OOS for 98 days, 4 hrs., and 1 min. Here are the cells:
Vehicle Date OOS Time OOS Date INS Time INS
ARFF 14 2019-02-25 13:20 2019-06-03 17:21
As you can see, the OOS time spans five months: Feb, Mar, Apr, May, and Jun.
I need to build VBA code that breaks those 98.16736111 days out into separate months: 3.24 days for Feb, 31.00 days for March…all the way out to 2.72 days for June.
What is the best way to build this code, taking into account leap years and date/time ranges that often fall within one month, but occasionally can be much longer?
Thank you very much in advance!
Win10 OS, Excel2010.
By: Mark Burns