Excel formula to work out time elapsed between dates based on very specific criteria

3

1

I have a dataset with approx. 29,000 entries related to approx. 3000 unique individuals’ admission and departure dates to and from a service over a period of time.

enter image description here

I’m trying to collapse each individuals’ service utilisation into discrete episodes in two separate ways:

1) Using a 30-day-gap exit criterion, meaning that all stays in the service in which the gap from one exit to the next entry is less than 30 days are considered to be part of one discrete episode. Thus, I need to build a formula that will allow me to check to see if there is a 30-day gap between when a person left and then re-entered the service (i.e. to see if an individual left the service for a period of 30 days before their next entry) and then sum the number of episodes associated with each unique individual in the service based on this 30-day exit criterion. This formula would then need to be applied to the whole dataset.

2)The same as above except using a 1-day-gap exit criterion.

Any help or direction with figuring out how best to go about doing this would be greatly appreciated.

Thanks in advance !

Jenny T

Posted 2018-04-09T11:23:03.770

Reputation: 41

1Why don't you try the DATEDIF Formula to calculate the elapsed days between Departure & Entry dates, and COUNTIF for number of violations. – Rajesh S – 2018-04-09T11:56:53.887

As @Rajesh said ^. Assuming the cell with "20/07/2011" is C2, This formula filled down from D2: =IF(DATEDIF(C2,B3,"D")>=30,"*","") will put an asterisk in every row where there is 30 or more days between the departure date and the next admission date. Then you can count the asterisks with COUNTIF(). You could also combine these into one formula. Here are links to more info on DATEDIF() and COUNTIF().

– Bandersnatch – 2018-04-09T16:26:19.657

@Jenny T does the solution proposed works? Appreciate if you can share the outcome of the formula's you'd tried. Someone did vote up your question which indicate that IS indeed a good quality question. If you're still struggling.. just share the details so that we can assist. IMHO, I really regret if this kind of good question (with info/screenshot/high clarity) goes into SU 'unanswered' list. – p._phidot_ – 2018-08-08T10:45:29.147

No answers