日期间隔计算

 1 public int monthDiff(date _start, date _end)
 2 {
 3     int diff;
 4     int startYear, startMonth;
 5     int endYear, endMonth;
 6     ;
 7     startYear  = year(_start);
 8     startMonth = mthofyr(_start);
 9     endYear    = year(_end);
10     endMonth   = mthofyr(_end);
11     //year
12     //endYear-startYear
13     
14     //diff=(endYear*12+endMonth) - (startYear*12+startMonth);
15     diff = (endYear - startYear) * 12 + (endMonth - startMonth);
16     return diff;
17 }
posted @ 2012-08-30 15:50  Sprite.z  Views(249)  Comments(0Edit  收藏  举报