13,249,174 members (36,091 online)
Rate this:
See more: , +
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.

Posted 22-Nov-12 20:01pm
ishandeb1.1K
__TR__ 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

Rate this:

## 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));
}
}```
v2
Rate this:

## Solution 2

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

Top Experts
Last 24hrsThis month
 phil.o 90 OriginalGriff 50 ppolymorphe 45 Ralf Meier 35 CPallini 30
 OriginalGriff 3,454 Karthik Bangalore 1,992 ppolymorphe 1,399 Dave Kreskowiak 1,276 CPallini 1,215