Don't compare strings with string representation of dates, compare time values in the form of structure
System.DateTime
.
First of all, do you really have to enter this data in edit box? Is some date-time or calendar picker feasible? — it would provide you with the value of the structure in first place.
For example, look at this article:
DateTimePicker Web Control[
^].
If you still want to get time from text, the conversion shown by Debata is correct.
When you have two instances of
DateTime
structure you can use operators "==", "!=" and ">", "<", ">=", "<=" in the sense "later", "earlier", "not earlier", "not later", respectively. Also, you can use subtraction operator ("-") which returns the result in the form of
System.TimeSpan
. This is a comprehensive set of operators to cover all your comparison needs.
—SA