//日期相减  获取天数
        function DateDiff(sDate1, sDate2)
        {
            var aDate, oDate1, oDate2, iDays
            aDate = sDate1.split("-")
            oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
            aDate = sDate2.split("-")
            oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
            iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数
            return iDays
        }

 

c#日期相减

     System.TimeSpan timeSpan = (System.TimeSpan)(DischargeDate - AdmissionDate);
     hidTreatDay.Value = timeSpan.Days.ToString();