Hello,
I have a sample data set below. I want to assign a quarter relative to a starting date (asofdate) such that the quarters fall on calendar quarters. Two examples below:
Dates 2/29 and 3/31 both fall within the 1st relative calendar quarter from 1/31/2024.
| AsOfDate_Out | SimDate_Out | Relative Quarter |
| 1/31/2024 | 2/29/2024 | 1 |
| 1/31/2024 | 3/31/2024 | 1 |
| 1/31/2024 | 4/30/2024 | 2 |
| 1/31/2024 | 5/31/2024 | 2 |
| 1/31/2024 | 6/30/2024 | 2 |
| 1/31/2024 | 7/31/2024 | 3 |
| 1/31/2024 | 8/31/2024 | 3 |
| 1/31/2024 | 9/30/2024 | 3 |
| 1/31/2024 | 10/31/2024 | 4 |
| 1/31/2024 | 11/30/2024 | 4 |
| 1/31/2024 | 12/31/2024 | 4 |
| 1/31/2024 | 1/31/2025 | 5 |
Only 6/30 falls within 1 relative calendar quarter from 5/30. 7/31 is the next relative calendar quarter from 5/31.
| AsOfDate_Out | SimDate_Out | Relative Quarter |
| 5/31/2024 | 6/30/2024 | 1 |
| 5/31/2024 | 7/31/2024 | 2 |
| 5/31/2024 | 8/31/2024 | 2 |
| 5/31/2024 | 9/30/2024 | 2 |
| 5/31/2024 | 10/31/2024 | 3 |
| 5/31/2024 | 11/30/2024 | 3 |
| 5/31/2024 | 12/31/2024 | 3 |
| 5/31/2024 | 1/31/2025 | 4 |
Last example where as of date starts on a calendar quarter end:
| AsOfDate_Out | SimDate_Out | Relative Quarter |
| 12/31/2023 | 1/31/2024 | 1 |
| 12/31/2023 | 2/29/2024 | 1 |
| 12/31/2023 | 3/31/2024 | 1 |
| 12/31/2023 | 4/30/2024 | 2 |
Any tips on how I can generate the Relative Calendar Quarter by inputting the AsOfDate and SimDate?
Thanks!