1

I would like to ask a question :( I'm already confuse since i want to show a message box that contains "Invalid Date" if datetimepicker1 is greater than datetimepicker2

Thank you for those who will help :)

3 Answers 3

1

You can check this way:

DateTime iDate;
      iDate = dateTimePicker1.Value;
    DateTime eDate;
      eDate = dateTimePicker2.Value;
    if (iDate > eDate ) {
      MessageBox.Show("Invalid Date.");
    }
Sign up to request clarification or add additional context in comments.

2 Comments

@Marvin Retro if the code solves your problem,please accept me as a answer
It works ! thank you for helping ! sorry for the spoonfeed question since i cant post a picture of my code and im on a rush and using my mobile :V ! thank you again :)
1
if (dateTimePicker1.Value > dateTimePicker2.Value ) {
  MessageBox.Show("Invalid Date.");
}

1 Comment

Thank you for answering my question :D
0

you Can set the value of datetimepicker1.MinimumDateTime(datetimepicker2.Value) or you can Compare the tow values with each other hope that helps :)

Update its the same as the answer i just needed to modify my answer to make it better and generic

 DateTime dateOne ;
  dateOne = dateTimePicker1.Value;
DateTime dateTow ;
  dateTow = dateTimePicker2.Value;
if (dateOne > dateTow  ) {console.writeline("Date Number One is Bigger")}

else{console.writeline("Date Number tow is Bigger");}

1 Comment

Thank you for answering my question ! god bless :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.