Trouble with an IF Statement

maic15

Active Member
Joined
Nov 17, 2004
Messages
313
I have two fields that contain dates: Start Date and End Date

I have another field (Week) that contains a string of dates.

I need to somehow write an IF Statement to compare the fields and return a value of 1 if True and 0 if False.

For example, If Start Date = 10/31/05 and End Date is 11/04/05 and Week = "10/31/05 - 11/04/05" , 1 should be returned. Since Week is text, there is no match.

So, my overall goal is IF Start Date and End Date are equal or between the Week string, then return 1, 0.
Thoughts?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
This seems to be working for me.

Where Start Date is in A2, End date is in B2, and the week string is in C2:
=IF(SEARCH(TEXT($A2:$B2,"mm/dd/yy"),$C2)>0,1,0)

This is an array formula--you have to press Ctrl+Shift+Enter after entering the formula for it to work correctly.
 
Upvote 0
That solved half of my problem. If Start Date is 11/01/05 and End Date is 11/04/05, then I need a 1 to be returned.

If Start Date and End Date are in the range of week return 1, 0)
 
Upvote 0
Hmm. This is working for me:
Book1
ABCD
1Start DateEnd DateWeek
210/31/200511/4/200510/31/05 - 11/4/051
310/29/200511/4/200510/31/05 - 11/4/050
411/1/200511/4/200510/31/05 - 11/4/051
Sheet1


Formula in C2 is:
=IF(($A2>=DATEVALUE(LEFT($C2,FIND(" ",$C2)-1)))*($B2<=DATEVALUE(MID($C2,FIND("-",$C2)+2,LEN($C2)))),1,0)

then copied down the column.
 
Upvote 0
One more condition that I forgot to apply.

If Start Date = 10/31/05 and End Date =11/16 and Week ="10/31/05 - 11/01/05", then return 1.

How do I add this condition?
 
Upvote 0
What exactly are the conditions, here?

Originally, you said: "If Start Date and End Date are equal or between the Week string, then return 1, 0."

But if Start Date = 10/31/05 and End Date =11/16 and Week ="10/31/05 - 11/01/05" ...the end date is not within the week date.

Basically, what I'm asking is what do you want? Does it not matter if the end date is past the week date?

Just a little confused, that's all...
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

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