IF between dates

pook_666

Board Regular
Joined
Aug 16, 2018
Messages
94
Hi magicians!

I'm trying to write an IF statement between dates.

I have a date in one column and if the date falls before, after or between a set of two dates I want an IF statement (or something that works!) to put a value in another cell.

Might be better if I gave you an example of what I'm trying to accomplish....see below where I want in cell D2 either P (date falls before start date in A2), F (date falls after end date in B2) or C (if date falls within these two dates of A2 and B2)

1640280244806.png


Hopefully I'm being clear enough for someone to help, if not will happily give additional information!

Thanks,
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You were on the right track.
try this
just made a minor change
Excel Formula:
=IF(C2<A2,"P",IF(C2>B2,"F",IF(AND(C2>A2,C2<B2),"C")))
1 call out. You may want to account for dates Equal to.
 
Upvote 0
By taking advantage of the order that the IFs are evaluated, you can shorten that a bit:

Book1
ABCD
1Start DateEnd DateCurrent DateC/P/F
212/1/202112/13/202112/23/2021F
Sheet26
Cell Formulas
RangeFormula
D2D2=IF(C2<A2,"P",IF(C2<B2,"C","F"))


And as bstory84 said, you can use < or <= as the operators to account for equals.
 
Upvote 0
Solution
No need for the final if, you can do it like
Excel Formula:
=IF(C2<A2,"P",IF(C2>B2,"F","C"))
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

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