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.
The above code is within a button click event.
Any help is appreciated.
Pravin GhadgePosted Dec 2, 2011, 2:29 AM
You can try this:
Mamta MPosted Dec 2, 2011, 12:07 AM
(DateTime.Compare(d1,d2) where d1 and d2 are the dates retrieved from your datepicker controls.
The output of the method will be one of three values:
Value Type
Condition
Less than zero
d1 is earlier than d2.
Zero
d1 is the same as d2.
Greater than zero
d1 is later than d2.