Ari

Ari

  • NA
  • 8
  • 50.1k

C# DateTimePicker problem

Dec 1 2011 10:13 PM
Hey, I'm trying to use some basic input validation for two dateTimePicker controls in an application I'm building.

I'm trying to set it so that the issueDatePicker's value or date & time must be smaller (less than) that of the dueDatePicker's value or date & time.

I'm using this code which seems correct but just isn't working..

                if (issueDatePicker.Value >= dueDatePicker.Value)
                {
                    MessageBox.Show("The due date must be greater than the issue date", "Input Error");
                }
                else
                {
                    issueDate = issueDatePicker.Value;
                    dueDate = dueDatePicker.Value;
                    dateCorrect = true;
                }

The above code is within a button click event.

Any help is appreciated.

Answers (2)