Date occurs within date range

brandon20

Board Regular
Joined
Feb 12, 2014
Messages
203
Hi,


I have two sets of data. I want to know if the date in one set occurs within the date range in the other set.
Either yes, or no.

Here is my data:
I pretty much would like to add a column to "Data set 1" that says yes or no, yes if the date in data set 1 occurs within the date range of data set two. I understand that there are multiple Well values with different date ranges, thats what makes this hard for me. I have to have the well and its corresponding date range match up with the well and date in data set 1.

Data Set 2
WellStart dateEnd Date
A8/12/20148/12/2014
A8/12/20148/12/2014
A8/12/20148/12/2014
A10/2/201411/5/2014
A8/12/20149/1/2014
B8/24/20133/15/2015
B8/24/20133/15/2015
C12/25/20133/15/2015
C12/25/20133/15/2015
C12/25/20133/15/2015

<colgroup><col><col><col></colgroup><tbody>
</tbody>




Data Set1
WellDate
A12/1/2014
A11/1/2014
A10/1/2014
A9/1/2014
B12/1/2014
B11/1/2014
B10/1/2014
B9/1/2014
B5/1/2014
B4/1/2014
B3/1/2014
B2/1/2014
B1/1/2014
B12/1/2013
B11/1/2013
B10/1/2013
B9/1/2013
B8/1/2013
B5/1/2013
B4/1/2013
B3/1/2013
B2/1/2013
B1/1/2013
B12/1/2012
B11/1/2012
B10/1/2012
B9/1/2012
B8/1/2012
B7/1/2012
B6/1/2012
B5/1/2012
B4/1/2012
B3/1/2012
B2/1/2012
B1/1/2012
B12/1/2011
C12/1/2014
C11/1/2014
C10/1/2014
C9/1/2014
C8/1/2014
C7/1/2014
C6/1/2014
C5/1/2014
C4/1/2014
C3/1/2014
C2/1/2014
C1/1/2014

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Row\Col
A​
B​
C​
D​
E​
F​
G​
1​
WellStart dateEnd DateWellDateY/N
2​
A
8/12/2014
8/12/2014
A
12/1/2014
N
3​
A
8/12/2014
8/12/2014
A
11/1/2014
Y
4​
A
8/12/2014
8/12/2014
A
10/1/2014
N
5​
A
10/2/2014
11/5/2014
A
9/1/2014
Y
6​
A
8/12/2014
9/1/2014
B
12/1/2014
Y
7​
B
8/24/2013
3/15/2015
B
11/1/2014
Y
8​
B
8/24/2013
3/15/2015
B
10/1/2014
Y
9​
C
12/25/2013
3/15/2015
B
9/1/2014
Y
10​
C
12/25/2013
3/15/2015
B
5/1/2014
Y
11​
C
12/25/2013
3/15/2015
B
4/1/2014
Y
12​
B
3/1/2014
Y

G2, control+shift+enter, not just enter, and copy down:

=IF(ISNUMBER(MATCH(1,IF($A$2:$A$11=E2,IF(F2>=$B$2:$B$11,IF(F2<=$C$2:$C$11,1))),0)),"Y","N")
 
Upvote 0
THANKS!

That helps tremendously.
I was wondering if it was possible to have the Y or N be an actual value from the spreadsheet instead.

Like if in your example column D was filled with letters A,B,C,D,E,F,G.... would it be possible to have the value from column D show instead of a simple Y or N?

I tried to do this a few different ways to no avail.

I normally would ask my end goal of the equation at the beginning but it gets to complicated to explain.

Thanks anyway!
 
Upvote 0
THANKS!

That helps tremendously.
I was wondering if it was possible to have the Y or N be an actual value from the spreadsheet instead.

Like if in your example column D was filled with letters A,B,C,D,E,F,G.... would it be possible to have the value from column D show instead of a simple Y or N?

I tried to do this a few different ways to no avail.

I normally would ask my end goal of the equation at the beginning but it gets to complicated to explain.

Thanks anyway!

What should be shown in G2 instead of N that you see in the exhibit I posted?
 
Upvote 0
Hi, I copied your example table and input "layer" values into column D and then added what I would like the output to look like into column G.
I have specific layers attributed to each of the start and end dates. If it is possible instead of the Y or N answer I would love the output to be the specific layer or layers that occur in that start and end date range.

For example, in well A, layer AC occurs in the start and end date range, so instead of Y it would be great if the output said layer AC.
But there is another issue. In well B there are two different layers that occur in the same start and end date range, layers G and D. Since both these layers occur in this date range it would be amazing if the output could say G,D or something of that sort.
Is this at all possible? Thank you for any help!


Row/ColABCDEFG
1WellStart dateEnd DateLayerWellDateY/N (Layer)
2A8/12/20148/12/2014CA12/1/2014N
3A8/12/20148/12/2014ABA11/1/2014AC
4A8/12/20148/12/2014ACA10/1/2014N
5A10/2/201411/5/2014ACA9/1/2014AC
6A8/12/20149/1/2014ACB12/1/2014G,D
7B8/24/20133/16/2015GB11/1/2014G,D
8B8/24/20133/16/2015DB10/1/2014G,D
9C12/25/20133/16/2015XB9/1/2014G,D
10C12/25/20133/16/2015XB5/1/2014G,D
11C12/25/20133/16/2015GB4/1/2014G,D

<colgroup><col><col><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Hi,
Maybe this clears things up.
Between the date range in row 5 for well A, the associated layer is Layer4, therefore I need layer4 to be displayed instead of the Y which was displayed previously.
Between the date range in row6 for well A, the associated layer is Layer5, therefore I need layer5 to be displayed instead of the Y which was displayed previously.

But, Well B in rows 7 and 8 has two different Layers which occur during the same date range. Because of this, if possible, I would like to display both layers in the cells in column G which fall under the date range for well B.



Row/ColABCDEFG
1WellStart dateEnd DateLayerWellDateY/N (Layer)
2A8/12/20148/12/2014Layer1A12/1/2014N
3A8/12/20148/12/2014Layer2A11/1/2014Layer4
4A8/12/20148/12/2014Layer3A10/1/2014N
5A10/2/201411/5/2014Layer4A9/1/2014Layer5
6A8/12/20149/1/2014Layer5B12/1/2014Layer6,Layer7
7B8/24/20133/16/2015Layer6B11/1/2014Layer6,Layer7
8B8/24/20133/16/2015Layer7B10/1/2014Layer6,Layer7
9C12/25/20133/16/2015Layer8B9/1/2014Layer6,Layer7
10C12/25/20133/16/2015Layer8B5/1/2014Layer6,Layer7
11C12/25/20133/16/2015Layer8B4/1/2014Layer6,Layer7

<colgroup><col><col><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>


I dont know if that answers your question though. I might clear it up I hope.


Thank you for your help
 
Upvote 0
G2, control+shift+enter, not just enter, and copy down:
Rich (BB code):

=REPLACE(aconcat(IF($A$2:$A$11=E2,IF(F2>=$B$2:$B$11,IF(F2<=$C$2:$C$11,", "&$D$2:$D$11,""),""),"")),1,2,"")

The VBA code for aconcat, which you must add to your workbook as a module, is shown below:

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,733
Members
449,185
Latest member
hopkinsr

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