show following year and passed

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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.
 
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.
 
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
 
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?
 
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?
 
DropDownList MyDDL = new DropDownList();
MyDDL.Items.Add(DateTime.Now.AddYears(1).ToString());
MyDDL.Items.Add(DateTime.Now.AddYears(-1).ToString());
 
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
 
I really have no idea what you are going on about, but i am glad that
whatever you did worked for you.
 
Back
Top