Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends...


i am using jquery plugin for datepicker.


in this i get month/day/year format

so i have 2 text feild for dates

Ex:

textfeild1: 09/24/2012

textfeild1: 12/25/2012

then i want to find out no of months between these 2 dates


plz help me... for this i am frustating from more days

Thanks & Regards

Mallesh(emailid deleted)
Posted
Updated 15-Jan-13 1:34am
v2
Comments
AshishChaudha 15-Jan-13 7:29am    
Don't repeat the question please.
Sandeep Mewara 15-Jan-13 13:49pm    
Why, where are you stuck?

Compliments of This answer
JavaScript
//Set the two dates
var currentTime   = new Date()
var currDate      = currentTime.getMonth() + 1 + "/" + currentTime.getDate() + "/" + currentTime.getFullYear() //Todays Date - implement your own date here.
var iniPastedDate = "8/7/2012" //Pasted Date - Implement your own date here.

//currDate = 8/17/12 and iniPastedDate = 8/7/12

function DateDiff(date1, date2) {
    var datediff = date1.getTime() - date2.getTime(); //store the getTime diff - or +
    return (datediff / (24*60*60*1000)); //Convert values to -/+ days and return value      
}

//Write out the returning value should be using this example equal -10 which means 
//it has pasted by ten days. If its positive the date is coming +10.    
document.write (DateDiff(new Date(iniPastedDate),new Date(currDate))); //Print the results...

The only thing you have to do from this answer is to get the month diff value.
 
Share this answer
 
 
Share this answer
 
v2
Comments
fjdiewornncalwe 15-Jan-13 11:48am    
The OP is asking for a javascript solution.
[no name] 16-Jan-13 1:21am    
Updated my links please check again. :)

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