h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Display Accounting Year of India

Indian Financial Year using C#.Net .
Indian Financial Year Starts with 01/04/yyyy To 31/03//yyyy.


private static string CurrentDate;
       
        public  static string SplitDay(DateTime dtp,string Mode)
        {
            string str = Convert.ToString(dtp);
            String.Format("{0:MM/dd/yyyy}", dtp);
            string[] st = str.Split('/');
            switch (Mode)
            {
                case "Day":
                    CurrentDate = st[1];
                    break;
                case "Month":
                    CurrentDate = st[0];
                    break;
                case "Year":
                    CurrentDate = st[2];
                    string[] s = CurrentDate.Split(' ');
                    CurrentDate = s[0];
                    break;
            }
            return CurrentDate;
        }

private void lstAccountYear(int statringYear)
        {
            string Day = ClsFinancialYear.SplitDay(DateTime.Now, "Day");
            string Month = ClsFinancialYear.SplitDay(DateTime.Now, "Month");
            string Year = ClsFinancialYear.SplitDay(DateTime.Now, "Year");
            int NextYear = Convert.ToInt32(Year) + 1;
            int LastYear = Convert.ToInt32(Year) - 1;
            int CurrentYear = Convert.ToInt32(Year);
                    if (Convert.ToInt32(Month) <= 3 && Convert.ToInt32(Year) == LastYear + 1)
                    {
                        for (int stYear = statringYear; stYear < CurrentYear; stYear++)
                        {
                            int next = stYear + 1;
                            listBox1.Items.Add(stYear + "-" + next);
                            listBox1.SelectedIndex = listBox1.Items.Count - 1;
                        }
                    }
                    else
                    {
                        for (int stYear = statringYear; stYear < NextYear ; stYear++)
                        {
                            int next = stYear + 1;
                            listBox1.Items.Add(stYear + "-" + next);
                            listBox1.SelectedIndex = listBox1.Items.Count - 1;
                        }
                    }
                }

Call this function in Form_load (where you want)

lstAccountYear(2010);
CurrentYear :2013
if Current date:01/04/2013
Result  :
2010-2011
2011-2012
2012-2013
2013-2014
else Current date:31/03/2013
2010-2011
2011-2012
2012-2013