Get financial year using C# :
// The following C# function used to get the Financial year from the given date
public static string GetFinancialYear(string cdate)
{
string finyear = "";
DateTime dt = Convert.ToDateTime(cdate);
int m = dt.Month;
int m = dt.Month;
int y = dt.Year;
if (m > 3)
{
finyear = y.ToString().Substring(2, 2) + "-" + Convert.ToString((y + 1)).Substring(2,2);
//get last two digits (eg: 10 from 2010);
//get last two digits (eg: 10 from 2010);
}
else
{
finyear = Convert.ToString((y - 1)).Substring(2, 2) + "-" + y.ToString().Substring(2, 2);
}
return finyear;
}
0 comments
Post a Comment