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.

Mamta MRank #268 · 9.4K reputationPosted Dec 1, 2011, 7:07 PM EST
(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.
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 1, 2011, 9:29 PM EST
You can try this: