Adding month to dropdownlist if next month will start in 5 or less days

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parshupooja
    New Member
    • Jun 2007
    • 159

    Adding month to dropdownlist if next month will start in 5 or less days

    Hey,

    I have dropdownlist where I am adding 2 values:

    Code:
    DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(-1).ToString("MMMM"), DateTime.Now.AddMonths(-1).ToString("M/yy")));
    DDCycle.Items.Add(new ListItem(DateTime.Now.ToString("MMMM"), DateTime.Now.ToString("M/yy")));
    I want to add below value if next month is about start in 5 or less days :

    Code:
     DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(1).ToString("MMMM"), DateTime.Now.AddMonths(1).ToString("M/yy")));
    Any idea?

    Thanks
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #2
    Originally posted by parshupooja
    Hey,

    I have dropdownlist where I am adding 2 values:

    Code:
    DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(-1).ToString("MMMM"), DateTime.Now.AddMonths(-1).ToString("M/yy")));
    DDCycle.Items.Add(new ListItem(DateTime.Now.ToString("MMMM"), DateTime.Now.ToString("M/yy")));
    I want to add below value if next month is about start in 5 or less days :

    Code:
     DDCycle.Items.Add(new ListItem(DateTime.Now.AddMonths(1).ToString("MMMM"), DateTime.Now.AddMonths(1).ToString("M/yy")));
    Any idea?

    Thanks
    Code:
    If Now.Day >= (Date.DaysInMonth(Now.Year, Now.Month) - 5) Then
    	DDCycle.Items.Add(....)
    End If
    This will do something if the day of the month is greater than the number of days in the current month less five.

    Comment

    • parshupooja
      New Member
      • Jun 2007
      • 159

      #3
      Thanks, it worked great

      Originally posted by balabaster
      Code:
      If Now.Day >= (Date.DaysInMonth(Now.Year, Now.Month) - 5) Then
      	DDCycle.Items.Add(....)
      End If
      This will do something if the day of the month is greater than the number of days in the current month less five.

      Comment

      Working...