Click here to Skip to main content
15,905,229 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
txtAge.Text = DateTime.Now.Year - Convert.ToDateTime(txtdate.Text).Year;

Here "Datetime" giving error..
Can any one solve this please...
Sandeep Mewara 29-Jul-10 4:02am    
Reason for my vote of 1
raju melveetilpurayil 31-Jul-10 13:50pm    
try to look its return type.

Give me money.

Demanding an answer will get you sarcasm and derision, nothing more.
Share this answer
First of all the title isn't very clear of what you really want to ask.

Second, consider casting your date to a string before putting in the Text property of txtAge.

Third, you should use the DateDiff function to determine the days? months? years? between the two dates.

System.TimeSpan diffResult = DateTime.Now.Subtract( Convert.ToDateTime(txtdate.Text));

txtAge.Text = diffResult.Years.ToString();

Good luck!
Share this answer
#realJSOP 29-Jul-10 5:43am    
Reason for my vote of 5
This is the answer, and should be marked as such.
raju melveetilpurayil 31-Jul-10 13:51pm    
I am supporting John Simmons / outlaw programmer. and accept my 5

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