Click here to Skip to main content
14,695,617 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
hi friends
i have to text box fist is birth date and second is join date and my problem is how to validate difference between 20 year birth date and join date pls help me
Posted

DateTime a, b;
a = Convert.ToDateTime(TextBox1.Text);
b = Convert.ToDateTime(TextBox2.Text);
System.TimeSpan span = b - a;
int days = (int)span.TotalDays + 1;


Now you have total days between these two dates.Perform actions accordingly.
   
v2
   
Comments
[no name] 21-May-13 2:34am
   
but my problem is how to validate in validation control
Aarti Meswania 21-May-13 2:50am
   
in asp you can do like this...
int year = DateDiff(DateInterval.Year, New Date(1978, 7, 9), Now);

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