Click here to Skip to main content
11,707,470 members (78,074 online)
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
Wes101392

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 Maciej Los 240
1 Mika Wendelius 220
2 OriginalGriff 168
3 Sergey Alexandrovich Kryukov 145
4 Peter Leow 140
0 OriginalGriff 9,198
1 Sergey Alexandrovich Kryukov 8,562
2 CPallini 5,189
3 Maciej Los 4,921
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2015
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