Click here to Skip to main content
15,886,639 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to calculate the difference between two dates and the result should get in Year,Month and Date format. While calculating the difference, it should take the end day also.

eg: 01/09/2012 - 30/09/2012 = 1 Month
01/02/2012 - 29/02/2012 = 1 Month
01/08/2012 - 10/08/2012 = 1 Month and 10 Days
01/01/2012 - 31/12/2012 = 1 Year
01/01/2012 - 10/01/2013 = 1 Year and 10 days
Posted

Check those links:

http://stackoverflow.com/questions/338463/how-do-i-do-a-date-comparison-in-javascript[^]
http://stackoverflow.com/questions/492994/compare-dates-with-javascript[^]

Both of them have nice information and good advice.

I've simply used Google searching "javascript compare dates".
 
Share this answer
 
if you r in vb.net then here is a solution...
DateDiff(DateInterval.Year, DTPDob.Value, DTPIncorpDT.Value)
 
Share this answer
 
Comments
[no name] 18-Sep-12 9:12am    
Where do you see VB.NET? It's clearly tagged as javascript.

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