# Referencing a date range in formulas

#1

Hello! I’m wondering how to reference a date range in a formula. I’d need to generate estimated grade levels for students by birth date. I would like to format this as a nested IF formula (ex. IF(Birthdate = [DATE RANGE], “Kindergarten”, IF(Birthdate=[DATE RANGE], “1st Grade”, (IF…and so on) - how do I reference a date range in this case?

Thanks for any assistance!

• Meg

#2

Nested IF statements work like an IF/ELSE statement, and the AND() allows you to test both the beginning of the range and the end of the range.

If you have a field named, “dob” use this formula in another field:

``````IF(
AND(dob >= "2014-01-01", dob <= "2014-12-31"),
"Date Range One",
IF(
AND(dob >= "2015-01-01",dob <= "2015-12-31"),
"Date Range Two",
IF(
AND(dob >= "2016-01-01",dob <= "2016-12-31"),
"Date Range Three",
"No Match"
)
)
)``````

#3

You don’t usually have to test both end of your range if you do your tests in the right order. Test the youngest grade first to see if their dob is less than the maximum, if not then you know the student is older and you don’t have to check agains the bottom of the range. Then test to see if the student is in 1st grade by checking the maximum value for dob (you already checked for K, so the test will never get to this point if the student is a kindergartener).

This approach makes your series of if statements more concise if a bit more abstract.

How to Reflect Filtered Records on One Table to Lookup in Another?
#4

@Tim_Wilson Great point! I guess I got a little too literal with the request

Here’s how that might look

``````IF(
dob <= "2014-12-31",
"Born 2014 or earlier",
IF(
dob <= "2015-01-01",
"Born in 2015",
IF(
dob <= "2016-12-31",
"Born in 2016",
"Born 2017 or later"
)
)
)``````