Alternatives
Members may post updates or alternatives to this current article in order to show different
approaches or add new features.
15 Jun 2011Sergey Alexandrovich Kryukov
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...
15 Jun 2011Abdullatif M. Abu Al Rub
You should use "date time picker" control instead of text boxes this is more professional as a developer.
DateTime fromdate = Convert.ToDateTime(TextBox1.Text);DateTime todate = Convert.ToDateTime(TextBox2.Text);if (todate.CompareTo(fromdate) < 0){//add you logic}
15 Jun 2011walterhevedeich
First, you need to convert the text to a DateTime value. From there, you can use DateTime.Compare[^] for this one. Check out the link.
15 Jun 2011koolprasad2003
Convert the dates to DATETIME object withDateTime.ParseExact()and then compare with comparison operator <
15 Jun 2011Ramalinga Koushik
Use this:DateTime fromdate = Convert.ToDateTime(TextBox1.Text);DateTime todate = Convert.ToDateTime(TextBox2.Text);if (todate.CompareTo(fromdate) < 0){//your code}
string s = "2011-06-16T05:07:57+0000";string t = "2011-07-16T06:07:57+0000";DateTime theDateA = DateTime.Parse(s);DateTime theDateB = DateTime.Parse(t);if (theDateB > theDateA){ // blah blah}Give it a try
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.