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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,858
1 OriginalGriff 278
2 Tadit Dash 260
3 Sergey Alexandrovich Kryukov 250
4 Peter Leow 220
0 Sergey Alexandrovich Kryukov 9,440
1 OriginalGriff 5,618
2 Peter Leow 4,280
3 Maciej Los 3,540
4 Abhinav S 3,363


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