12,503,838 members (50,190 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 19: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
 OriginalGriff 455 Maciej Los 208 F-ES Sitecore 170 CPallini 105 ppolymorphe 95
 OriginalGriff 7,133 ppolymorphe 3,874 Maciej Los 3,541 David_Wimbley 2,872 Karthik Bangalore 2,742