Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript
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 15-Jan-13 2:15am
Edited 15-Jan-13 2:34am
v2
Comments
AshishChaudha at 15-Jan-13 7:29am
   
Don't repeat the question please.
Sandeep Mewara at 15-Jan-13 13:49pm
   
Why, where are you stuck?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Compliments of This answer
//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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
v2
Comments
Marcus Kramer at 15-Jan-13 11:48am
   
The OP is asking for a javascript solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 449
1 Maciej Los 430
2 OriginalGriff 320
3 CHill60 240
4 CPallini 210
0 Sergey Alexandrovich Kryukov 10,102
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100