Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello friends
I create a small application where user enter their date of birth and application convert it total days according to current date.
Posted

1 solution

TimeSpan will help you.

Have a look at this example (Birthday 10 June 1975):

C#
DateTime birthday = new DateTime(1975, 6, 10);

DateTime today = DateTime.Now.Date;

TimeSpan duration = today.Subtract(birthday);

int totalDays = (int)duration.TotalDays;
 
Share this answer
 
Comments
ZurdoDev 15-May-15 8:16am    
+5
TheRealSteveJudge 15-May-15 8:20am    
Thank you!
Maciej Los 15-May-15 8:42am    
5ed!
TheRealSteveJudge 15-May-15 8:59am    
Thank you!
Member 10273293 15-May-15 8:45am    
thank you sir
it is helpfull for me

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