Hi All,
I am facing a critical issue when I compare my dates and display error is the start date is greater than the end date. Here is my code... I am making use of Datetime picker.
private void datetimepicker1 _ValueChanged(o bject sender, EventArgs e)
{
Datetime dt1 = datetimepicker1 .value;
Datetime dt2 = datetimepicker2 .value;
if(dt1 > dt2)
{
Messagebox.show ("Start date cannot be greater than end date");
datetimepicker1 .value = datetimepicker2 .value;
return;
}
}
This code executes well if I am selecting dates in the same calendar month. If I select the start date to be somewhere in April and the end date is march, the control goes into loop and displays the above message box infinite times.....
Please help....
Thanks,
I am facing a critical issue when I compare my dates and display error is the start date is greater than the end date. Here is my code... I am making use of Datetime picker.
private void datetimepicker1 _ValueChanged(o bject sender, EventArgs e)
{
Datetime dt1 = datetimepicker1 .value;
Datetime dt2 = datetimepicker2 .value;
if(dt1 > dt2)
{
Messagebox.show ("Start date cannot be greater than end date");
datetimepicker1 .value = datetimepicker2 .value;
return;
}
}
This code executes well if I am selecting dates in the same calendar month. If I select the start date to be somewhere in April and the end date is march, the control goes into loop and displays the above message box infinite times.....
Please help....
Thanks,
Comment