but the day X is not known and will always be different.
Input 08.02.22 = Output 01.03.21 (old business year)
Input 04.04.22 = Output 01.03.22 (new business year)
Input 03.05.22 = Output 01.03.22 (new business year)
CurrentDateString is today’s date, 05/01/22, and would be the input string FinancialYearString is the financial year end, "01/03/" + DateTime.Now.ToString("yy") CurrentDate and FinancialYear are both DateTime variables, you can Parse these as a DateTime to compare with the following code: DateTime.ParseExact(DateString,"dd/MM/yy",CultureInfo.InvariantCulture)
If the current date is before the financial year end, you would do FinancialYearEnd.AddYears(-1) to remove a year from the DateTime variable FinancialYearEnd
In this case we have to use string replace function to divide the month and year and comparing the year with the current year and inside of that you could use the above condition what i have suggested. please refer the below attached code for your requirement. check and let us know if it suits your requirement. thanks.