woodycanuck
Board Regular
- Joined
- Dec 18, 2009
- Messages
- 54
- Office Version
- 365
I have a challenging problem involving date math. For context, this data has to do with calculating a criminal defendant's prior convictions to figure out sentencing. The task is, for each prior conviction, figure out how many days it was before the current offense date. But we need to exclude any time the person was violating probation. Then count how many of those old offenses are less than 2 years old after the excluded time.
Here is a sample. "Start date" shows 3 prior conviction dates, "End Date" is the current offense date, and there are two spans of time that must be excluded from the calculation. Notice that sometimes the exclusion period overlaps an old offense date, so of course we only exclude the portion after the old offense date (it could also extend past the current offense date, same idea). I need to be able to do this for any number of priors, and any set of excluded date ranges. Is it possible to do this in a formula to answer the question: For an offense date of X, how many countable priors does this person have?
Here is a sample. "Start date" shows 3 prior conviction dates, "End Date" is the current offense date, and there are two spans of time that must be excluded from the calculation. Notice that sometimes the exclusion period overlaps an old offense date, so of course we only exclude the portion after the old offense date (it could also extend past the current offense date, same idea). I need to be able to do this for any number of priors, and any set of excluded date ranges. Is it possible to do this in a formula to answer the question: For an offense date of X, how many countable priors does this person have?
HelpMeDodger.xlsx | ||||||||
---|---|---|---|---|---|---|---|---|
B | C | D | E | F | G | |||
22 | Start Dates | End Date | Exclude from | Exclude to | ||||
23 | 1/01/15 | 1/01/18 | 6/01/16 | 7/01/16 | ||||
24 | 1/01/16 | 1/01/14 | 6/01/15 | |||||
25 | 1/01/17 | |||||||
Sheet1 |