Fixed date within a financial year

Hi, I need your help again.

Our financial year always runs from 01.03. - 28.02… In my process I always need the 01.03. of the current business year.

Example:
05.01.22 = result should be 01.03.21
01.02.22 = result should be 01.03.21
01.04.22 = result should be 01.03.22

Can you give me a tip here?

Thank you in advance for your help.

Nina

Hi @nina.wenner, where are taking this input from and it is of what type?

Hi @shreyash_shirbhate, this is the current date!

Okay @nina.wenner

Please use below syntax :

Date.now.Adddays(X).tostring(“dd/MM/YY”)

you can add the number instead of X. For eg. if you want to add days you can use (30) or if you want to substract then you can use (-30)

@shreyash_shirbhate

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)

Hi @nina.wenner ,

what about below code.

if Now.Month<=3

then → “01.03.”+Now.AddYears(-1).ToString(“yyyy”)
Else → “01.03.”+Now.ToString(“yyyy”)

1 Like

Hi @nina.wenner,

If you have the two dates to compare, you can ParseExact the dates and compare them in an If statement. For example:

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
image

I hope this helps

1 Like

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.

Financial Year Demo.zip (2.6 KB)

@kirankumar.mahanthi1, yes great that’s how it works.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.