show following year and passed

G

Guest

I have a drop down where I'm showing 3/31/2006 and the passed 5 years, I need
to also show month end for the following year and still show the passed 5 .

So I need 12/31/2007 and back 5 years from today, how can I do this?
 
G

Guest

Hello CSharpguy - If I understand your question correctly, I would think that
DateTime is your friend. You can use a DateTime object and then call the
appropriate method .AddDays(), .AddMonths(), or AddYears() - add negative
numbers to go backwards. It will do all the all the calendar stuff for you.
 
T

tdavisjr

What about the DateTime.AddYears(int value) Method?

You can use a loop to to pass in a variable year as the parameter to
this method and add that date to the dropdown list. Passing a negative
value with go back a year, and a positive value will add a year.
 
G

Guest

You want to play with the system.DateTime class. E.g.

System.DateTime.Now.AddYears(1) will return a DateTime object that is todays
date next year

System.DateTime.Now.AddYears(-3) will return a DAtTime from 3 years ago.
 
G

Guest

I tried the addyears() and it just showe 4/30/2007 - 4/30/2006 - 4/30/2005,
etc.

I need to get end of month for all months for one year ahead and 5 years back
 
G

Guest

The end of the month is on the same day every year, i.e. the end of january
is the 31st in whatever year it is. What exactly do you mean?
 
G

Guest

the thing is I need to show the dates in the same drop down box. I can get
passed years, I got future years, but how can I now put them into one drop
down?
 
G

Guest

DropDownList MyDDL = new DropDownList();
MyDDL.Items.Add(DateTime.Now.AddYears(1).ToString());
MyDDL.Items.Add(DateTime.Now.AddYears(-1).ToString());
 
G

Guest

I was able to get it to work without doing that. I just made a change to the
addMonths() and got it working in the same dropdown
 
G

Guest

I really have no idea what you are going on about, but i am glad that
whatever you did worked for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top