Formula with date ranges

sunrise06

Active Member
Joined
Oct 27, 2006
Messages
264
Office Version
  1. 365
Platform
  1. Windows
I have a long column of dates that I want to segment by year. For example, =IF(AND(C2>=8/1/2018,C2<=7/30/2019),"2018-2019",""). This will give me for one year, but how do I write the formula for say a 10 year span of dates so that 8/1/2017<>7/30/2018 will then give me 2017-2018, etc?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You will need to continue on the same line of thought and create a nested if statement:
=IF(AND(C2>=8/1/2018,C2<=7/30/2019),"2018-2019",AND(C2>=8/1/2017,C2<=7/30/2018),"2017-2018","")
And so on...
 
Upvote 0
Thanks, I am getting an error - You've entered too many arguments for this function.
 
Upvote 0
Here's another thought that formats the range based on relative position from August 1st.
=IF(0 < DAYS(DATE(YEAR(C2),8,1),C2),TEXT(YEAR(C2) -1,"####")&"-"&TEXT(YEAR(C2),"####"),TEXT(YEAR(C2),"####")&"-"&TEXT(YEAR(C2)+1,"####"))
 
Upvote 0
Forgot to add the IF portion

=IF(AND(C2>=8/1/2018,C2<=7/30/2019),"2018-2019",IF(AND(C2>=8/1/2017,C2<=7/30/2018),"2017-2018",""))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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