Returning 1 or 0 based on multiple dates

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
597
Office Version
  1. 365
Hi

At the moment I have the following formula - =
Excel Formula:
IF(AND($G$2<>"",R$1>$G2,R$1<$H2),1,0)
whereby there is a start date is column G, and an end date in column H, and its look at the column headers for dates to see if a date is between them. The formaula works fine, however, I have multiple datart/end dates in a row, and rather than keep writing the formula out, is there an easier win (there can be anywhere between 1 lot of start/end dates, to 15 start/end dates.

Hopefully below is correct, but essentially its any Start/End date combination that the dates fall between, - so in the date ranges if the last day of the month falls between them, I need a 1, and if not a 0. There will be no overlapping dates between different start/end date combinations.

All rows will have at least one start/end date.

Column G -
StartDate 1
Column H -
End Date 1
Column I -
StartDate 2
Column J -
End Date 2
Column K -
Start Date 3
Column L -
End Date 3
Column AA -
31/03/23
Column AB -
30/04/23
Column AC -
31/05/23
Column AD -
30/06/23
Column AE -
31/07/23
15/03/2318/05/2311000
15/03/2302/04/2305/04/2302/05/2311000
15/04/2301/05/2301/06/2301/07/2301010
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
  • There is no column R shown in your sample data to understand the exact situation.
  • Post a larger sample data using XL2BB.
  • Do you need these 0s, 1s for any further calculation or what?
 
Upvote 0
Suppose first start_date starts from odd column (column G) (in formula there is ISODD then ISEVEN. If actual range start from even column, i.e column H, use ISEVEN then ISODD next)

Book1
GHIJKLZAAABACADAEAFAG
1Start Date 1End Date 1Start Date 2End Date 2Start Date 3End Date 331-03-2330-04-2331-05-2330-06-2331-07-2331-08-2330-09-23
215-03-2318-05-231100000
315-03-2302-04-2305-04-2302-05-231100000
415-04-2301-05-2301-06-2301-07-230101000
Sheet1
Cell Formulas
RangeFormula
AB1:AG1AB1=EOMONTH(AA1,1)
AA2:AG4AA2=SUMPRODUCT(((AA$1>=$G2:$K2)*ISODD(COLUMN($G2:$K2)))*(AA$1<=$H2:$L2)*ISEVEN(COLUMN($H2:$L2)))
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

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