         var flag = 0
         var shiftdetailarray = List<ShiftDetailDB>()
         
-        let shiftnsdate = MonthlySalaryShow().DateSerial(CommonMethod().Changecalendar(shiftcours.sy, calender: "JP"), month: shiftcours.sm, day: 1)
-        let c = NSCalendar.currentCalendar()
-        let monthrange = c.rangeOfUnit([NSCalendarUnit.Day],  inUnit: [NSCalendarUnit.Month], forDate: shiftnsdate)
+        //1クールが全部で何日間あるかを判断するため
+        let monthrange = self.GetShiftCoursMonthRange(shiftcours.sy, shiftstartmonth: shiftcours.sm)
         
         var shiftdetaildbrecordcount = DBmethod().DBRecordCount(ShiftDetailDB)
         let shiftdbrecordcount = DBmethod().DBRecordCount(ShiftDB)

        DBmethod().AddandUpdate(newshiftdbsalalyadd, update: true)
    }
    
}


        
        //1クールが全部で何日間あるかを判断するため
        let shiftyearandmonth = CommonMethod().JudgeYearAndMonth(staffarray[0])
        let monthrange = self.GetShiftCoursMonthRange(shiftyearandmonth.startcoursmonthyear, shiftstartmonth: shiftyearandmonth.startcoursmonth)

        //先に空要素を1クール分追加しておく
        for(var i = 0; i < monthrange.length; i++){
            dayshiftarray.append("")
