Formula determine if a date falls between a specific M/D range for multiple years for YTD comparison.

flashgordie

Board Regular
Joined
Jan 9, 2008
Messages
95
Office Version
  1. 365
Platform
  1. Windows
Hello, I have a report that consists of transactions over a number of years. In E12, I have added a column and used =YEAR(D12)+(MONTH(D12)>=12) to calculate which fiscal year a transaction fall into as out year runs Dec 1 to Nov 30.
  • I would like to add a second column (F) and I am hoping someone could suggest another formula that could be added starting at F12 to calculate if the transaction date (Month and Day) falls within a range, if so, return the fiscal year. It if does not, it would be considered “out of range”.

  • The range would be specified by the user by entering a starting point (F4, month and day) and an end point (F5, month and day). Although maybe I’m over thinking this, but I wonder if this will create its own challenge as dates in excel consist of all 3 elements – MM/DD/YY, but I am hoping we could find a solution so that I would just use month and day.
Any help would be appreciated.

Thank you!

Book11
ABCDEFG
1
2
3
41-DecStart Date
524-MayEnd date
6
7
8
9
10Dec 1 to Nov 30
11Trans DateFiscal PeriodYTD Range
1211/30/20152015"not in range"
1312/1/201520162016
141/12/201620162016
155/6/201620162016
167/6/201620162016
1711/20/201620162016
181/25/201720172017
197/1/20172017"not in range"
2012/21/201720182018
215/2/201820182018
226/2/20182018"not in range"
2311/16/20182018"not in range"
241/21/201920192019
258/4/20192019"not in range"
2610/12/20192019"not in range"
2711/30/20192019"not in range"
2812/1/201920202020
292/21/202020202020
306/6/20202020"not in range"
3111/11/20202020"not in range"
321/16/202120212021
333/23/202120212021
3412/12/202120222022
352/16/202220222022
3611/7/20222022"not in range"
371/12/202320232023
385/23/202320232023
395/24/202320232023
405/25/20232023"not in range"
Sheet1
Cell Formulas
RangeFormula
E12:E40E12=YEAR(D12)+(MONTH(D12)>=12)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
MrExcelPlayground17.xlsx
DEFG
41-DecStart Date
524-MayEnd date
6
7
8
9
10Dec 1 to Nov 30
11Trans DateFiscal PeriodYTD Range
1211/30/20152015"not in range"not in range
1312/1/2015201620162016
141/12/2016201620162016
155/6/2016201620162016
167/6/201620162016not in range
1711/20/201620162016not in range
181/25/2017201720172017
197/1/20172017"not in range"not in range
2012/21/2017201820182018
215/2/2018201820182018
226/2/20182018"not in range"not in range
2311/16/20182018"not in range"not in range
241/21/2019201920192019
258/4/20192019"not in range"not in range
2610/12/20192019"not in range"not in range
2711/30/20192019"not in range"not in range
2812/1/2019202020202020
292/21/2020202020202020
306/6/20202020"not in range"not in range
3111/11/20202020"not in range"not in range
321/16/2021202120212021
333/23/2021202120212021
3412/12/2021202220222022
352/16/2022202220222022
3611/7/20222022"not in range"not in range
371/12/2023202320232023
385/23/2023202320232023
395/24/2023202320232023
405/25/20232023"not in range"not in range
Sheet20
Cell Formulas
RangeFormula
E12:E40E12=YEAR(D12)+(MONTH(D12)=12)
G12:G40G12=LET(m,MONTH(D12),d,DAY(D12),mm,MONTH($F$4),dd,DAY($F$4),mmm,MONTH($F$5),ddd,DAY($F$5),t,DATE(IF(m=12,1999,2000),m,d),tt,DATE(IF(mm=12,1999,2000),mm,dd),ttt,DATE(IF(mmm<12,2000,1999),mmm,ddd),IF(AND(t>=tt,t<=ttt),E12,"not in range"))
 
Upvote 1
=LET(m,MONTH(D12),d,DAY(D12),mm,MONTH($F$4),dd,DAY($F$4),mmm,MONTH($F$5),ddd,DAY($F$5),t,DATE(IF(m=12,1999,2000),m,d),tt,DATE(IF(mm=12,1999,2000),mm,dd),ttt,DATE(IF(mmm<12,2000,1999),mmm,ddd),IF(AND(t>=tt,t<=ttt),E12,"not in range"))

Hi James, Thank you so much for helping me. This is very close. sooooo close. However, I noticed that when I adjust the start date from Dec 1st to an earlier time , the formula indicates none of the transaction dates are within range. Any ideas?
 
Upvote 0
I have it with the fiscal year. So from what I figured, starting before Dec 1 wouldn't make any sense. But I guess it does make sense.

For example, if you wanted to see between Nov 1 and Jan 30, Anything in November would be the prior fiscal year.
 
Upvote 0
I have it with the fiscal year. So from what I figured, starting before Dec 1 wouldn't make any sense. But I guess it does make sense.

For example, if you wanted to see between Nov 1 and Jan 30, Anything in November would be the prior fiscal year.
Yes, you are correct. For the most part it is likely to start with the fiscal year, but we also deal with seasonality. Which means I might be looking to compare Nov 1 to Mar 1 (winter months) from 1 year to the next. Obviously the date range to be compared YOY could not be any greater than 365 days. Would you have any options for this? Again, Thanks very much for your help!!!
 
Upvote 0
See if the following formula works for you:
Excel Formula:
=IF(MOD(TEXT(D12,"mmdd")-TEXT($F$4,"mmdd"),1200)+MOD(TEXT($F$5,"mmdd")-TEXT(D12,"mmdd"),1200)=MOD(TEXT($F$5,"mmdd")-TEXT($F$4,"mmdd"),1200),E12,"Not in range")
 
Upvote 1
Solution
@JamesCanale and @Tetra201 ..... Thank you so much for your help. Both answers work well with each doing something a little different. In @JamesCanale case, it sees the start date of the range being equal to the start of the fiscal year, while in @Tetra201 solution, the start and end of the date range can be altered. I very much appreciate the help!!!
 
Upvote 0

Forum statistics

Threads
1,223,863
Messages
6,175,052
Members
452,607
Latest member
OoM_JaN

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