rutuja.y
(Rutuja Y)
October 19, 2021, 4:45am
1
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
Charbel1
(Charbel)
October 19, 2021, 4:59am
2
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
ppr
(Peter Preuss)
October 19, 2021, 8:58am
4
@rutuja.y
in addition to:
we can do:
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
rutuja.y
(Rutuja Y)
October 19, 2021, 10:37am
5
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
Charbel1
(Charbel)
October 19, 2021, 2:21pm
6
Adding an IF condition to @ppr proposed syntax:
Forum_FinancialYears.xaml (6.3 KB)
This gives proper output like you mentioned.
Best,
Charbel
ppr
(Peter Preuss)
October 19, 2021, 2:23pm
7
@rutuja.y please avoid duplicates. Your request is handle on your other topic:
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