Click here to Skip to main content
13,090,091 members (49,647 online)
Rate this:
Please Sign up or sign in to 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 14-Oct-12 20:30pm

1 solution

Rate this: bad
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[^]
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2017
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