Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hi all, im having problems validating two dates together, they work and everything but it also allows the user to enter a "To Date" that is smaller than the "From Date", how can i compare the two dates to ensure that the "To Date" is greater than the "From Date".

help would be appreciated thanks alot
Posted

1 solution

Try with DateTime.Compare Method[^]

Or else try something like this:
string s = "2012-10-01";
string t = "2012-10-16";

DateTime theDateA = DateTime.Parse(s);
DateTime theDateB = DateTime.Parse(t);

if (theDateB > theDateA)
{
   // Your code here
}


..and for more look here[^], and also similar threads on CP Search[^]
 
Share this answer
 
Comments
Wes101 15-Oct-12 2:44am    
Thanks alot it worked
Prasad_Kulkarni 15-Oct-12 2:47am    
You're welcome!
Kindly hit green button to formally accept solution, if it's really helpful for you. So other will get reference through this answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900