Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
__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
DATE between @InputDate AND DATEADD(YEAR,5,@InputDate)

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

C#
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));
}
}
 
Share this answer
 
v2
private void GetFinYear(int givenYear)
{
for(int i=1; i<=5; i++)
{
comboBox1.Items.Add(givenYear.toString() + " - " + (GivenYear+i).toString());
++givenYear;
}
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900