Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 14-Oct-12 20:30pm
Wes101381

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Comments
Wes101 at 15-Oct-12 2:44am
   
Thanks alot it worked
Prasad_Kulkarni at 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)

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,240
3 George Jonsson 3,584
4 Gihan Liyanage 2,625


Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100