Recently in the calendar, give two days to calculate the difference between the date of this OK, but also to calculate the month a tense did not think out, find on the internet, found, a look, in fact, the method is very simple is not thought
Multiply the year of the date 1 with 12, plus the month of the date 1,
Put the date 2 the same operation
And then subtract two months from the month difference,
Does anyone say that you can do it in a year?
The answer is yes,
Paste Code
The original idea wasn't me.
//Two of dates vardate1 = ' 2016-02-26 '; varDate2 = ' 2015-11-10 '; //Split Month DayDate1 = Date1.split ('-')); //get the number of monthsDate1 = parseint (date1[0]) * + parseint (date1[1]); //Split Month DayDate2 = Date2.split ('-')); //get the number of monthsDate2 = parseint (date2[0]) * + parseint (date2[1]); varm = Math.Abs (Date1-date2); Alert (m);
Did you figure that out, Chung-like,
Find the month of difference based on the two fixed dates provided