Click here to Skip to main content
14,425,416 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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".
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

if you r in vb.net then here is a solution...
DateDiff(DateInterval.Year, DTPDob.Value, DTPIncorpDT.Value)
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100