Formula to look between 2 dates

Eurekaonide

Active Member
Joined
Feb 1, 2010
Messages
433
Hi
Wonder if you can help please.
I have a table with the months running along the top one month to each column (it defaults to the 1st of each month) so I have also added in above it the last day of each month.
so in column c row 1 it would say 31/10/2022 and in column c row 2 it would say 01/10/2022
Now in Row 3 column A is my start date and column B is an end date

what I want is for a formula to place a 1 in the C column (onwards) if the start date is between 1st-31st October and to place a 1 if the end date is between these dates.
this is so that each month it will show either a blank or a 1 depending on when something starts and finishes.

I had this but it doesnt seem to work

=IF(AND(A3<=C2,B3>=C1),1,"")

any help appreciated thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about
Excel Formula:
=IF(AND($A3<=C$1,$B3>=C$2),1,"")
 
Upvote 0
Do you wnat either date to be in the month, or both dates to be in the month?
if either, then maybe this?
Mr Excel Questions.xlsx
ABCD
110/31/2022
2StartEnd10/1/2022
39/5/20229/30/2022 
410/5/202210/6/20221
510/25/202211/5/20221
611/5/202211/10/2022 
7
Sheet7
Cell Formulas
RangeFormula
C3:C6C3=IF(OR( AND(A3>$C$2,A3<$C$1), AND(B3>$C$2,B3<$C$1) ),1,"")
 
Upvote 0
Do you wnat either date to be in the month, or both dates to be in the month?
if either, then maybe this?
Mr Excel Questions.xlsx
ABCD
110/31/2022
2StartEnd10/1/2022
39/5/20229/30/2022 
410/5/202210/6/20221
510/25/202211/5/20221
611/5/202211/10/2022 
7
Sheet7
Cell Formulas
RangeFormula
C3:C6C3=IF(OR( AND(A3>$C$2,A3<$C$1), AND(B3>$C$2,B3<$C$1) ),1,"")
Thanks I cant seem to get it to work.
what happens is
if the start date is before 01/10/2022 it puts it to blank which is correct but if the start date is 01/10/2022 if doesnt place a 1 the current end date is way out 31/12/2040 so I just want it to put a 1 in each column between dates I just cant seem to make it do it. I can if I just work on a start date but not when I want it to look at both start and end.
 
Upvote 0
In that case you need to do a better job of explaining what you want & at the same time post some sample data showing what you want.
 
Upvote 0
If you want the First and Last Days of the month, then put "=" with the "<,>" signs.
=IF(OR( AND(A3>=$C$2,A3<=$C$1), AND(B3>=$C$2,B3<=$C$1) ),1,"")

To help us help you.. what do you want to see as the result in the possible scenarios that I have given with the solution I proposed?
10/31/2022​
StartEnd
10/1/2022​
05/09/2022​
30/09/2022​
????
15/09/2022​
25/10/2022​
????
01/10/2022​
20/10/2022​
????
05/10/2022​
06/10/2022​
????
25/10/2022​
31/10/2022​
????
28/10/2022​
25/11/2022​
????
 
Upvote 0
If you want the First and Last Days of the month, then put "=" with the "<,>" signs.
=IF(OR( AND(A3>=$C$2,A3<=$C$1), AND(B3>=$C$2,B3<=$C$1) ),1,"")

To help us help you.. what do you want to see as the result in the possible scenarios that I have given with the solution I proposed?
10/31/2022​
StartEnd
10/1/2022​
05/09/2022​
30/09/2022​
"Blank" as not yet started
15/09/2022​
25/10/2022​
"Blank" as not yet started
01/10/2022​
20/10/2022​
1 as started within the month of October (would be a blank in the following month in Nov as it finished in Oct)
05/10/2022​
06/10/2022​
1 as started within the month of October (would be a blank in the following month in Nov as it finished in Oct)
25/10/2022​
31/10/2022​
1
28/10/2022​
25/11/2022​
1 as started in Oct and would also be a 1 in the next column for Nov but Dec would be blank
Thanks - hopefully the above helps.
 
Upvote 0
I don't understand why the 2nd row would be blank for Oct, but the last row would be 1 for Nov.
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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