Calculate financial year According to input date

If my variable stores value out_strBillPeriod =jul 2021…that means value vary monthly in format MMM yyyy…so how I can calculate financial year according to this value?

Want output in this format 2021-2022

Financial year start from April…

so I want if the input is Jun 2021…output . 2021-2022
And if month is before April i.e Mar 2021 …output . 2020-2021

Hello,

The following expression will return 2021:

DateTime.ParseExact("jun 2021", "MMM yyyy", System.Globalization.CultureInfo.InvariantCulture).Year

and this one will return 2022:

(DateTime.ParseExact("jun 2021", "MMM yyyy", System.Globalization.CultureInfo.InvariantCulture).Year)+1

You can concatenate them by converting them to strings:

outStr = var1.ToString + "-" var2.ToString

Best,
Charbel

Hi

Let’s do it in a one single expression in a simple way

If you have your Datetime in string variable named
out_strBillPeriod

Then use a assign activity like this

str_output =
Split(out_strBillPeriod.ToString.Trim,” “)(1).ToString+“ - “ +(Convert.ToInt(Split(out_strBillPeriod.ToString.Trim,” “)(1).ToString)+1).ToString

Cheers @rutuja.y

@rutuja.y
in addition to:

we can do:
grafik
String.Format("{0}-{1}",CDate("jul 2021").Year,CDate("jul 2021").Year + 1)

feel free to work with a variable like:

intfYear = CDate("jul 2021").Year
strPeriod= String.Format("{0}-{1}",intfYear ,intfYear + 1)
1 Like

Financial year start from April…

so I want if the input is Jun 2021…output . 2021-2022
And if month is before April i.e Mar 2021 …output . 2020-2021

Adding an IF condition to @ppr proposed syntax:

Forum_FinancialYears.xaml (6.3 KB)

This gives proper output like you mentioned.

Best,
Charbel

@rutuja.y please avoid duplicates. Your request is handle on your other topic: