static int MthDiff1(date d1, date d2)
{
int daysDiff = d1 - d2 - 1;
if (daysDiff >= 0)
return (year(num2date(daysDiff)) - 1900)*12 + mthofyr(num2date(daysDiff));
else
return -1 * (year(num2date(-1 * daysDiff)) - 1900) * 12 + mthofyr(num2date(daysDiff)) ;
}
static int MthDiff2(date d1, date d2)
{
;
return year(d1) * 12 + mthofyr(d1) - year(d2) * 12 - mthofyr(d2) ;
}
原文地址:http://www.cnblogs.com/AllenFeng/p/3800529.html