Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how should i validate a textbox not to tk date more than the current date
Posted

 
Share this answer
 
v2
you can use the Compare method of date time to check the date.
for example:



C#
DateTime date1 =  Convert.ToDateTime(txtbox1.Text);
DateTime dt = DateTime.Now;
int result = DateTime.Compare(date1, dt );
string relationship;

if (result < 0)
   relationship = "is earlier than";
else if (result == 0)
   relationship = "is the same time as";         
else
   relationship = "is later than";
 
Share this answer
 
v2

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