John Smith

John Smith

  • NA
  • 8
  • 6.1k

Using Month Only in DateTime

Sep 9 2010 5:20 PM
I only want to change the MonthlyCalender Month to a variable(May) but for some reason i have to enter the full date which breaks my code, as i search for the month in the variable and then match it so it then excutes the code when it finds the string, below is the code;

             if (textDueDate.Contains("May"))
            {
                DateTime dt = new DateTime();
                clndDueDate.SetDate(dt.AddMonths(05));
                clndDueDate.Update();
                MessageBox.Show("Inside May");
            }
            else
            {

            }

This does nothing, So do i use SetDate property in a different way... since i added the month on the Monthly calender.

MessageBox is just my debugger :P

Maybe substring?

 DateTime dt = new DateTime(2001, 01, 01); //Works with full date

DateTime dt = new DateTime(null, 01, null); //Not working ;(

Thanks for reading

Answers (6)