Solved How to write an IF statement that includes a date range

April 15, 2015 at 07:55:05
Specs: Windows 7
I need to create an if statement that says:

if cell AD15 is between July 1, 2006 and June 30, 2007, return 2006, if not return "stop"

Many thanks, C


See More: How to write an IF statement that includes a date range

Report •

#1
April 15, 2015 at 09:43:17
I figured it out myself! Convert the dates to numbers and then create the statement
=IF(AND(AE15>=38899,AE15<39264),"2006","stop")

Report •

#2
April 15, 2015 at 12:59:57
✔ Best Answer
Glad you came up with your own solution.
Here is one that uses the DATE function, might be a bit easier to understand:

=IF(AND(AE15>=DATE(2006,7,1),AE15<DATE(2007,6,30)),2006,"Stop")

Notice I did NOT surround 2006 with quotes.
When you surround a number with quotes, it becomes TEXT
and could cause confusion, unless you want the 2006 to be a text string.

Also, Excel questions are best asked in the Office Software Forum.

MIKE

http://www.skeptic.com/


Report •
Related Solutions


Ask Question