Click here to Skip to main content
11,719,973 members (80,768 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server Ajax , +
Hi all,

I need to get a result of financial years(...2011-2012, 2012-2013, 2013-2014) starting from the date given by me to till 5 year in a dropdown list.

I have no idea of how to do this. I don't even know whether it is possible or not.

Any kind of help would be Appreciated.



Thanking you in advance,
Posted 22-Nov-12 19:01pm
ishandeb1.1K
Comments
__TR__ at 23-Nov-12 1:41am
   
If your looking to retrieve records for next 5 years from a given date you can use DATEADD[^] function in sql server.
Your sql query will have something like this in the where clause
DATE between @InputDate AND DATEADD(YEAR,5,@InputDate)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Let say we received the given date from text box:-

private void button1_Click(object sender, EventArgs e)
{
DateTime GivenDate = Convert.ToDateTime(textBox1.Text);
int GivenYear = GivenDate.Year;
 
for(int i=0; i<5; i++)
{
comboBox1.Items.Add(GivenYear + i + "-" + (GivenYear + 1 + i));
}
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

private void GetFinYear(int givenYear)
{
for(int i=1; i<=5; i++)
{
comboBox1.Items.Add(givenYear.toString() + " - " + (GivenYear+i).toString());
++givenYear;
}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 OriginalGriff 309
2 F-ES Sitecore 225
3 Suvendu Shekhar Giri 140
4 Maciej Los 100
0 Sergey Alexandrovich Kryukov 1,869
1 OriginalGriff 770
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


Advertise | Privacy | Mobile
Web04 | 2.8.150901.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100